src/Entity/AddressRegion.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\LifecycleTrait;
  4. use App\Repository\AddressRegionRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. #[ORM\Entity(repositoryClassAddressRegionRepository::class)]
  10. class AddressRegion
  11. {
  12.     use LifecycleTrait;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     #[Groups("simpleRegion")]
  17.     private ?int $id;
  18.     #[ORM\Column(type'string'length200)]
  19.     #[Groups("simpleRegion")]
  20.     private ?string $label;
  21.     #[ORM\Column(type'string'length200)]
  22.     #[Groups("simpleRegion")]
  23.     private ?string $ncc;
  24.     #[ORM\Column(type'string'length2)]
  25.     #[Groups("simpleRegion")]
  26.     private ?string $code;
  27.     #[ORM\Column(type'string'length5)]
  28.     private ?string $codeChefLieu;
  29.     /**
  30.      * Type de nom en clair :
  31.      * Permet de gérer correctement l'intégration du label dans une phrase
  32.      * https://www.insee.fr/fr/information/3718969#tncc
  33.      */
  34.     #[ORM\Column(type'string'length1)]
  35.     private ?string $tnnc;
  36.     #[ORM\OneToMany(mappedBy'region'targetEntityAddressDepartment::class)]
  37.     private Collection $departments;
  38.     #[ORM\OneToMany(mappedBy'region'targetEntityPromotion::class)]
  39.     private Collection $promotions;
  40.     #[ORM\OneToMany(mappedBy'addressRegion'targetEntityRegion::class)]
  41.     private Collection $regions;
  42.     public function __construct()
  43.     {
  44.         $this->lifeCycleTraitInit();
  45.         $this->departments = new ArrayCollection();
  46.         $this->promotions = new ArrayCollection();
  47.         $this->regions = new ArrayCollection();
  48.     }
  49.     public function __toString()
  50.     {
  51.         return $this->getLabel();
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getLabel(): ?string
  58.     {
  59.         return $this->label;
  60.     }
  61.     public function setLabel($label): static
  62.     {
  63.         $this->label $label;
  64.         return $this;
  65.     }
  66.     public function getNcc(): ?string
  67.     {
  68.         return $this->ncc;
  69.     }
  70.     public function setNcc($ncc): static
  71.     {
  72.         $this->ncc $ncc;
  73.         return $this;
  74.     }
  75.     public function getCode(): ?string
  76.     {
  77.         return $this->code;
  78.     }
  79.     public function setCode($code): static
  80.     {
  81.         $this->code $code;
  82.         return $this;
  83.     }
  84.     public function getCodeChefLieu(): ?string
  85.     {
  86.         return $this->codeChefLieu;
  87.     }
  88.     public function setCodeChefLieu($codeChefLieu): static
  89.     {
  90.         $this->codeChefLieu $codeChefLieu;
  91.         return $this;
  92.     }
  93.     public function getTnnc(): ?string
  94.     {
  95.         return $this->tnnc;
  96.     }
  97.     public function setTnnc($tnnc): static
  98.     {
  99.         $this->tnnc $tnnc;
  100.         return $this;
  101.     }
  102.     public function getDepartments(): Collection
  103.     {
  104.         return $this->departments;
  105.     }
  106.     public function addDepartment(AddressDepartment $department): self
  107.     {
  108.         if (!$this->departments->contains($department)) {
  109.             $this->departments[] = $department;
  110.             $department->setRegion($this);
  111.         }
  112.         return $this;
  113.     }
  114.     public function removeDepartment(AddressDepartment $department): self
  115.     {
  116.         if ($this->departments->removeElement($department)) {
  117.             // set the owning side to null (unless already changed)
  118.             if ($department->getRegion() === $this) {
  119.                 $department->setRegion(null);
  120.             }
  121.         }
  122.         return $this;
  123.     }
  124.     public function getPromotions(): Collection
  125.     {
  126.         return $this->promotions;
  127.     }
  128.     public function addPromotion(Promotion $promotion): self
  129.     {
  130.         if (!$this->promotions->contains($promotion)) {
  131.             $this->promotions[] = $promotion;
  132.             $promotion->setRegion($this);
  133.         }
  134.         return $this;
  135.     }
  136.     public function removePromotion(Promotion $promotion): self
  137.     {
  138.         if ($this->promotions->removeElement($promotion)) {
  139.             // set the owning side to null (unless already changed)
  140.             if ($promotion->getRegion() === $this) {
  141.                 $promotion->setRegion(null);
  142.             }
  143.         }
  144.         return $this;
  145.     }
  146.     public function getRegions(): Collection
  147.     {
  148.         return $this->regions;
  149.     }
  150.     public function addRegion(Region $region): self
  151.     {
  152.         if (!$this->regions->contains($region)) {
  153.             $this->regions[] = $region;
  154.             $region->setAddressRegion($this);
  155.         }
  156.         return $this;
  157.     }
  158.     public function removeRegion(Region $region): self
  159.     {
  160.         if ($this->regions->removeElement($region)) {
  161.             // set the owning side to null (unless already changed)
  162.             if ($region->getAddressRegion() === $this) {
  163.                 $region->setAddressRegion(null);
  164.             }
  165.         }
  166.         return $this;
  167.     }
  168. }