src/Entity/Departement.php line 151

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * Copyright (C) Office National de Publication et de Communication - All Rights Reserved
  5.  *
  6.  * Unauthorized copying of this file, via any medium is strictly prohibited by law
  7.  * This file is proprietary and confidential
  8.  */
  9. namespace App\Entity;
  10. use App\Common\CoordonneesInterface;
  11. use App\Common\LieuInterface;
  12. use App\Entity\Common\IdAsStringTrait;
  13. use App\Entity\Common\IsEmptyTrait;
  14. use App\Entity\Common\UpdatableTrait;
  15. use Doctrine\Common\Collections\ArrayCollection;
  16. use Doctrine\Common\Collections\Collection;
  17. use Doctrine\ORM\Mapping as ORM;
  18. use Gedmo\Mapping\Annotation as Gedmo;
  19. /**
  20.  * @ORM\Entity(repositoryClass="App\Repository\DepartementRepository")
  21.  * @ORM\Table(
  22.  *     name="departement",
  23.  *     indexes={
  24.  *         @ORM\Index(columns={"libelle", "slug"})
  25.  *     }
  26.  * )
  27.  */
  28. class Departement implements LieuInterface
  29. {
  30.     use DepartementElasticTrait;
  31.     use IdAsStringTrait;
  32.     use IsEmptyTrait;
  33.     use UpdatableTrait;
  34.     /**
  35.      * @ORM\Column(type="string", length=150, nullable=true, unique=true)
  36.      * @Gedmo\Slug(fields={"libelle", "id"})
  37.      */
  38.     private $slug;
  39.     /** @ORM\Column(type="string", nullable=true) */
  40.     private $libelle;
  41.     /** @ORM\ManyToOne(targetEntity="AncienneRegion", inversedBy="departements", cascade={"persist"}) */
  42.     private $ancienneRegion;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity="Ville", mappedBy="departement")
  45.      * @ORM\OrderBy({"libelle": "ASC"})
  46.      */
  47.     private $villes;
  48.     /** @ORM\OneToOne(targetEntity="DepartementCoordonnees", mappedBy="departement") */
  49.     private $coordonnees;
  50.     /**
  51.      * @ORM\OneToMany(targetEntity="App\Entity\Etablissement", mappedBy="departement")
  52.      */
  53.     private $etablissements;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity="App\Entity\Region", inversedBy="departements")
  56.      */
  57.     private $region;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $onglets;
  62.     public function __construct()
  63.     {
  64.         $this->villes = new ArrayCollection();
  65.         $this->etablissements = new ArrayCollection();
  66.     }
  67.     public function setSlug(string $slug): void
  68.     {
  69.         $this->slug $slug;
  70.     }
  71.     public function getSlug(): ?string
  72.     {
  73.         return $this->slug;
  74.     }
  75.     public function setLibelle(string $libelle): void
  76.     {
  77.         $this->libelle $libelle;
  78.     }
  79.     public function getLibelle(): ?string
  80.     {
  81.         return $this->libelle;
  82.     }
  83.     public function getLibelleAvecCode(): ?string
  84.     {
  85.         $libelle $this->libelle;
  86.         if ($this->id) {
  87.             $libelle trim($libelle.' ('.$this->id.')');
  88.         }
  89.         return $libelle;
  90.     }
  91.     public function setAncienneRegion(AncienneRegion $ancienneRegion): void
  92.     {
  93.         $this->ancienneRegion $ancienneRegion;
  94.     }
  95.     public function getAncienneRegion(): ?AncienneRegion
  96.     {
  97.         return $this->ancienneRegion;
  98.     }
  99.     public function addVille(Ville $ville): void
  100.     {
  101.         $this->villes[] = $ville;
  102.     }
  103.     public function removeVille(Ville $ville): void
  104.     {
  105.         $this->villes->removeElement($ville);
  106.     }
  107.     public function getVilles(): Collection
  108.     {
  109.         return $this->villes;
  110.     }
  111.     public function setCoordonnees(DepartementCoordonnees $coordonnees): void
  112.     {
  113.         $this->coordonnees $coordonnees;
  114.     }
  115.     public function getCoordonnees(): ?CoordonneesInterface
  116.     {
  117.         return $this->coordonnees;
  118.     }
  119.     public function getRegion(): ?Region
  120.     {
  121.         $ancienneRegion $this->getAncienneRegion();
  122.         return $ancienneRegion $ancienneRegion->getRegion() : null;
  123.     }
  124.     /**
  125.      * @return Collection|Etablissement[]
  126.      */
  127.     public function getEtablissements(): Collection
  128.     {
  129.         return $this->etablissements;
  130.     }
  131.     public function addEtablissement(Etablissement $etablissement): self
  132.     {
  133.         if (!$this->etablissements->contains($etablissement)) {
  134.             $this->etablissements[] = $etablissement;
  135.             $etablissement->setDepartement($this);
  136.         }
  137.         return $this;
  138.     }
  139.     public function removeEtablissement(Etablissement $etablissement): self
  140.     {
  141.         if ($this->etablissements->contains($etablissement)) {
  142.             $this->etablissements->removeElement($etablissement);
  143.             // set the owning side to null (unless already changed)
  144.             if ($etablissement->getDepartement() === $this) {
  145.                 $etablissement->setDepartement(null);
  146.             }
  147.         }
  148.         return $this;
  149.     }
  150.     public function setRegion(?Region $region): self
  151.     {
  152.         $this->region $region;
  153.         return $this;
  154.     }
  155.     public function getOnglets(): ?string
  156.     {
  157.         return $this->onglets;
  158.     }
  159.     public function setOnglets(?string $onglets): self
  160.     {
  161.         $this->onglets $onglets;
  162.         return $this;
  163.     }
  164. }