src/Entity/Company/Presentation.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Company;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Entity\Company\Juridiction;
  5. use App\Entity\Utils\TimestampTrait;
  6. use App\Entity\Department\Department;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\Company\PresentationRepository")
  12.  * @UniqueEntity(fields={"name"}, message="Ce nom existe déjà")
  13.  * @ORM\HasLifecycleCallbacks()
  14.  */
  15. class Presentation
  16. {
  17.     use TimestampTrait;
  18.     
  19.     /**
  20.      * @ORM\Id()
  21.      * @ORM\GeneratedValue()
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      */
  28.     private $name;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      */
  32.     private $abbreviation;
  33.     /**
  34.      * @ORM\Column(type="text")
  35.      */
  36.     private $description;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity="App\Entity\Company\Juridiction", mappedBy="nature")
  39.      */
  40.     private $juridictions;
  41.     /**
  42.      * @ORM\ManyToMany(targetEntity=Department::class, mappedBy="natures")
  43.      */
  44.     private $departments;
  45.     public function __construct()
  46.     {
  47.         $this->juridictions = new ArrayCollection();
  48.         $this->departments = new ArrayCollection();
  49.     }
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getName(): ?string
  55.     {
  56.         return $this->name;
  57.     }
  58.     public function setName(string $name): self
  59.     {
  60.         $this->name $name;
  61.         return $this;
  62.     }
  63.     public function getAbbreviation(): ?string
  64.     {
  65.         return $this->abbreviation;
  66.     }
  67.     public function setAbbreviation(string $abbreviation): self
  68.     {
  69.         $this->abbreviation $abbreviation;
  70.         return $this;
  71.     }
  72.     public function getDescription(): ?string
  73.     {
  74.         return $this->description;
  75.     }
  76.     public function setDescription(string $description): self
  77.     {
  78.         $this->description $description;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return Collection|Juridiction[]
  83.      */
  84.     public function getJuridictions(): Collection
  85.     {
  86.         return $this->juridictions;
  87.     }
  88.     public function addJuridiction(Juridiction $juridiction): self
  89.     {
  90.         if (!$this->juridictions->contains($juridiction)) {
  91.             $this->juridictions[] = $juridiction;
  92.             $juridiction->setNature($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removeJuridiction(Juridiction $juridiction): self
  97.     {
  98.         if ($this->juridictions->contains($juridiction)) {
  99.             $this->juridictions->removeElement($juridiction);
  100.             // set the owning side to null (unless already changed)
  101.             if ($juridiction->getNature() === $this) {
  102.                 $juridiction->setNature(null);
  103.             }
  104.         }
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection|Department[]
  109.      */
  110.     public function getDepartments(): Collection
  111.     {
  112.         return $this->departments;
  113.     }
  114.     public function addDepartment(Department $department): self
  115.     {
  116.         if (!$this->departments->contains($department)) {
  117.             $this->departments[] = $department;
  118.             $department->addNature($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeDepartment(Department $department): self
  123.     {
  124.         if ($this->departments->contains($department)) {
  125.             $this->departments->removeElement($department);
  126.             $department->removeNature($this);
  127.         }
  128.         return $this;
  129.     }
  130. }