src/Entity/PosteDirector.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PosteDirectorRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass=PosteDirectorRepository::class)
  10.  */
  11. class PosteDirector  extends EntityBase
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\OneToMany(targetEntity=Poste::class, mappedBy="posteDirector")
  21.      * @Assert\NotBlank()
  22.      */
  23.     private $postes;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=Employee::class)
  26.      * @ORM\JoinColumn(nullable=false)
  27.      * @Assert\NotBlank()
  28.      */
  29.     private $responsable;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=Localite::class, inversedBy="posteDirectors")
  32.      * @Assert\NotBlank()
  33.      */
  34.     private $localite;
  35.     /**
  36.      * @ORM\OneToMany(targetEntity=Employee::class, mappedBy="posteDirector")
  37.      */
  38.     private $employees;
  39.     public function __construct()
  40.     {
  41.         $this->postes = new ArrayCollection();
  42.         $this->employees = new ArrayCollection();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     /**
  49.      * @return Collection<int, Poste>
  50.      */
  51.     public function getPostes(): Collection
  52.     {
  53.         return $this->postes;
  54.     }
  55.     public function addPoste(Poste $poste): self
  56.     {
  57.         if (!$this->postes->contains($poste)) {
  58.             $this->postes[] = $poste;
  59.             $poste->setPosteDirector($this);
  60.         }
  61.         return $this;
  62.     }
  63.     public function removePoste(Poste $poste): self
  64.     {
  65.         if ($this->postes->removeElement($poste)) {
  66.             // set the owning side to null (unless already changed)
  67.             if ($poste->getPosteDirector() === $this) {
  68.                 $poste->setPosteDirector(null);
  69.             }
  70.         }
  71.         return $this;
  72.     }
  73.     public function getResponsable(): ?Employee
  74.     {
  75.         return $this->responsable;
  76.     }
  77.     public function setResponsable(?Employee $responsable): self
  78.     {
  79.         $this->responsable $responsable;
  80.         return $this;
  81.     }
  82.     public function getLocalite(): ?Localite
  83.     {
  84.         return $this->localite;
  85.     }
  86.     public function setLocalite(?Localite $localite): self
  87.     {
  88.         $this->localite $localite;
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return Collection<int, Employee>
  93.      */
  94.     public function getEmployees(): Collection
  95.     {
  96.         return $this->employees;
  97.     }
  98.     public function addEmployee(Employee $employee): self
  99.     {
  100.         if (!$this->employees->contains($employee)) {
  101.             $this->employees[] = $employee;
  102.             $employee->setPosteDirector($this);
  103.         }
  104.         return $this;
  105.     }
  106.     public function removeEmployee(Employee $employee): self
  107.     {
  108.         if ($this->employees->removeElement($employee)) {
  109.             // set the owning side to null (unless already changed)
  110.             if ($employee->getPosteDirector() === $this) {
  111.                 $employee->setPosteDirector(null);
  112.             }
  113.         }
  114.         return $this;
  115.     }
  116. }