2022-03-06 18:25:46 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
|
|
|
use App\Core\Entity\EntityInterface;
|
|
|
|
use App\Repository\EstablishmentRepository;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Entity(repositoryClass=EstablishmentRepository::class)
|
|
|
|
*/
|
|
|
|
class Establishment implements EntityInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @ORM\Id
|
|
|
|
* @ORM\GeneratedValue
|
|
|
|
* @ORM\Column(type="integer")
|
|
|
|
*/
|
2022-04-15 16:45:58 +02:00
|
|
|
protected $id;
|
2022-03-06 18:25:46 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Column(type="string", length=255)
|
|
|
|
*/
|
2022-04-15 16:45:58 +02:00
|
|
|
protected $name;
|
2022-03-06 18:25:46 +01:00
|
|
|
|
2022-06-26 19:08:40 +02:00
|
|
|
use AddressTrait;
|
2022-03-06 18:25:46 +01:00
|
|
|
|
|
|
|
/**
|
2022-04-15 16:45:58 +02:00
|
|
|
* @ORM\OneToMany(targetEntity=EstablishmentGroup::class, mappedBy="establishment", orphanRemoval=true, cascade={"persist", "remove"})
|
2022-03-06 18:25:46 +01:00
|
|
|
*/
|
2022-04-15 16:45:58 +02:00
|
|
|
protected $establishmentGroups;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\ManyToMany(targetEntity=Project::class, mappedBy="establishments")
|
|
|
|
*/
|
|
|
|
protected $projects;
|
2022-03-06 18:25:46 +01:00
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
2022-04-15 16:45:58 +02:00
|
|
|
$this->establishmentGroups = new ArrayCollection();
|
|
|
|
$this->projects = new ArrayCollection();
|
2022-03-06 18:25:46 +01:00
|
|
|
}
|
|
|
|
|
2022-03-06 19:12:11 +01:00
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
return $this->getName();
|
|
|
|
}
|
|
|
|
|
2022-03-06 18:25:46 +01:00
|
|
|
public function getId(): ?int
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(): ?string
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setName(string $name): self
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-04-15 16:45:58 +02:00
|
|
|
* @return Collection<int, EstablishmentGroup>
|
2022-03-06 18:25:46 +01:00
|
|
|
*/
|
2022-04-15 16:45:58 +02:00
|
|
|
public function getEstablishmentGroups(): Collection
|
2022-03-06 18:25:46 +01:00
|
|
|
{
|
2022-04-15 16:45:58 +02:00
|
|
|
return $this->establishmentGroups;
|
2022-03-06 18:25:46 +01:00
|
|
|
}
|
|
|
|
|
2022-04-15 16:45:58 +02:00
|
|
|
public function addEstablishmentGroup(EstablishmentGroup $establishmentGroup): self
|
2022-03-06 18:25:46 +01:00
|
|
|
{
|
2022-04-15 16:45:58 +02:00
|
|
|
if (!$this->establishmentGroups->contains($establishmentGroup)) {
|
|
|
|
$this->establishmentGroups[] = $establishmentGroup;
|
|
|
|
$establishmentGroup->setEstablishment($this);
|
2022-03-06 18:25:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2022-04-15 16:45:58 +02:00
|
|
|
public function removeEstablishmentGroup(EstablishmentGroup $establishmentGroup): self
|
2022-03-06 18:25:46 +01:00
|
|
|
{
|
2022-04-15 16:45:58 +02:00
|
|
|
if ($this->establishmentGroups->removeElement($establishmentGroup)) {
|
2022-03-06 18:25:46 +01:00
|
|
|
// set the owning side to null (unless already changed)
|
2022-04-15 16:45:58 +02:00
|
|
|
if ($establishmentGroup->getEstablishment() === $this) {
|
|
|
|
$establishmentGroup->setEstablishment(null);
|
2022-03-06 18:25:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2022-04-15 16:45:58 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection<int, Project>
|
|
|
|
*/
|
|
|
|
public function getProjects(): Collection
|
|
|
|
{
|
|
|
|
return $this->projects;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addProject(Project $project): self
|
|
|
|
{
|
|
|
|
if (!$this->projects->contains($project)) {
|
|
|
|
$this->projects[] = $project;
|
|
|
|
$project->addEstablishment($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function removeProject(Project $project): self
|
|
|
|
{
|
|
|
|
if ($this->projects->removeElement($project)) {
|
|
|
|
$project->removeEstablishment($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2022-03-06 18:25:46 +01:00
|
|
|
}
|