105 lines
2.2 KiB
PHP
105 lines
2.2 KiB
PHP
|
<?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;
|
||
|
|
||
|
/**
|
||
|
* @ORM\Entity(repositoryClass=EstablishmentGroupRepository::class)
|
||
|
*/
|
||
|
class EstablishmentGroup implements EntityInterface
|
||
|
{
|
||
|
/**
|
||
|
* @ORM\Id
|
||
|
* @ORM\GeneratedValue
|
||
|
* @ORM\Column(type="integer")
|
||
|
*/
|
||
|
protected $id;
|
||
|
|
||
|
/**
|
||
|
* @ORM\Column(type="string", length=255)
|
||
|
*/
|
||
|
protected $label;
|
||
|
|
||
|
/**
|
||
|
* @ORM\ManyToOne(targetEntity=Establishment::class, inversedBy="establishmentGroups")
|
||
|
* @ORM\JoinColumn(nullable=false)
|
||
|
*/
|
||
|
protected $establishment;
|
||
|
|
||
|
/**
|
||
|
* @ORM\ManyToMany(targetEntity=Intervention::class, mappedBy="establishmentGroups")
|
||
|
*/
|
||
|
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;
|
||
|
}
|
||
|
}
|