125 lines
2.9 KiB
PHP
125 lines
2.9 KiB
PHP
<?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")
|
|
*/
|
|
protected $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=255)
|
|
*/
|
|
protected $name;
|
|
|
|
use AddressTrait;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity=EstablishmentGroup::class, mappedBy="establishment", orphanRemoval=true, cascade={"persist", "remove"})
|
|
*/
|
|
protected $establishmentGroups;
|
|
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity=Project::class, mappedBy="establishments")
|
|
*/
|
|
protected $projects;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->establishmentGroups = new ArrayCollection();
|
|
$this->projects = new ArrayCollection();
|
|
}
|
|
|
|
public function __toString()
|
|
{
|
|
return $this->getName();
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, EstablishmentGroup>
|
|
*/
|
|
public function getEstablishmentGroups(): Collection
|
|
{
|
|
return $this->establishmentGroups;
|
|
}
|
|
|
|
public function addEstablishmentGroup(EstablishmentGroup $establishmentGroup): self
|
|
{
|
|
if (!$this->establishmentGroups->contains($establishmentGroup)) {
|
|
$this->establishmentGroups[] = $establishmentGroup;
|
|
$establishmentGroup->setEstablishment($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeEstablishmentGroup(EstablishmentGroup $establishmentGroup): self
|
|
{
|
|
if ($this->establishmentGroups->removeElement($establishmentGroup)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($establishmentGroup->getEstablishment() === $this) {
|
|
$establishmentGroup->setEstablishment(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @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;
|
|
}
|
|
}
|