2022-04-15 16:46:06 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
|
|
|
use App\Core\Entity\EntityInterface;
|
|
|
|
use App\Repository\EstablishmentGroupRepository;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
2022-12-19 18:35:10 +01:00
|
|
|
#[ORM\Entity(repositoryClass: EstablishmentGroupRepository::class)]
|
2022-04-15 16:46:06 +02:00
|
|
|
class EstablishmentGroup implements EntityInterface
|
|
|
|
{
|
2022-12-19 18:35:10 +01:00
|
|
|
#[ORM\Id]
|
|
|
|
#[ORM\GeneratedValue]
|
|
|
|
#[ORM\Column(type: 'integer')]
|
2022-04-15 16:46:06 +02:00
|
|
|
protected $id;
|
|
|
|
|
2022-12-19 18:35:10 +01:00
|
|
|
#[ORM\Column(type: 'string', length: 255)]
|
2022-04-15 16:46:06 +02:00
|
|
|
protected $label;
|
|
|
|
|
2022-12-19 18:35:10 +01:00
|
|
|
#[ORM\ManyToOne(targetEntity: Establishment::class, inversedBy: 'establishmentGroups')]
|
|
|
|
#[ORM\JoinColumn(nullable: false)]
|
2022-04-15 16:46:06 +02:00
|
|
|
protected $establishment;
|
|
|
|
|
2022-12-19 18:35:10 +01:00
|
|
|
#[ORM\ManyToMany(targetEntity: Intervention::class, mappedBy: 'establishmentGroups')]
|
2022-04-15 16:46:06 +02:00
|
|
|
protected $interventions;
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->interventions = new ArrayCollection();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
return (string) $this->getLabel();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getId(): ?int
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLabel(): ?string
|
|
|
|
{
|
|
|
|
return $this->label;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setLabel(string $label): self
|
|
|
|
{
|
|
|
|
$this->label = $label;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEstablishment(): ?Establishment
|
|
|
|
{
|
|
|
|
return $this->establishment;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setEstablishment(?Establishment $establishment): self
|
|
|
|
{
|
|
|
|
$this->establishment = $establishment;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection<int, Intervention>
|
|
|
|
*/
|
|
|
|
public function getInterventions(): Collection
|
|
|
|
{
|
|
|
|
return $this->interventions;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addIntervention(Intervention $intervention): self
|
|
|
|
{
|
|
|
|
if (!$this->interventions->contains($intervention)) {
|
|
|
|
$this->interventions[] = $intervention;
|
|
|
|
$intervention->addEstablishmentGroup($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function removeIntervention(Intervention $intervention): self
|
|
|
|
{
|
|
|
|
if ($this->interventions->removeElement($intervention)) {
|
|
|
|
$intervention->removeEstablishmentGroup($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|