<?phpnamespace App\Entity;use App\Entity\Traits\LifecycleTrait;use App\Repository\AddressRegionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\Entity(repositoryClass: AddressRegionRepository::class)]class AddressRegion{ use LifecycleTrait; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] #[Groups("simpleRegion")] private ?int $id; #[ORM\Column(type: 'string', length: 200)] #[Groups("simpleRegion")] private ?string $label; #[ORM\Column(type: 'string', length: 200)] #[Groups("simpleRegion")] private ?string $ncc; #[ORM\Column(type: 'string', length: 2)] #[Groups("simpleRegion")] private ?string $code; #[ORM\Column(type: 'string', length: 5)] private ?string $codeChefLieu; /** * Type de nom en clair : * Permet de gérer correctement l'intégration du label dans une phrase * https://www.insee.fr/fr/information/3718969#tncc */ #[ORM\Column(type: 'string', length: 1)] private ?string $tnnc; #[ORM\OneToMany(mappedBy: 'region', targetEntity: AddressDepartment::class)] private Collection $departments; #[ORM\OneToMany(mappedBy: 'region', targetEntity: Promotion::class)] private Collection $promotions; #[ORM\OneToMany(mappedBy: 'addressRegion', targetEntity: Region::class)] private Collection $regions; public function __construct() { $this->lifeCycleTraitInit(); $this->departments = new ArrayCollection(); $this->promotions = new ArrayCollection(); $this->regions = new ArrayCollection(); } public function __toString() { return $this->getLabel(); } public function getId(): ?int { return $this->id; } public function getLabel(): ?string { return $this->label; } public function setLabel($label): static { $this->label = $label; return $this; } public function getNcc(): ?string { return $this->ncc; } public function setNcc($ncc): static { $this->ncc = $ncc; return $this; } public function getCode(): ?string { return $this->code; } public function setCode($code): static { $this->code = $code; return $this; } public function getCodeChefLieu(): ?string { return $this->codeChefLieu; } public function setCodeChefLieu($codeChefLieu): static { $this->codeChefLieu = $codeChefLieu; return $this; } public function getTnnc(): ?string { return $this->tnnc; } public function setTnnc($tnnc): static { $this->tnnc = $tnnc; return $this; } public function getDepartments(): Collection { return $this->departments; } public function addDepartment(AddressDepartment $department): self { if (!$this->departments->contains($department)) { $this->departments[] = $department; $department->setRegion($this); } return $this; } public function removeDepartment(AddressDepartment $department): self { if ($this->departments->removeElement($department)) { // set the owning side to null (unless already changed) if ($department->getRegion() === $this) { $department->setRegion(null); } } return $this; } public function getPromotions(): Collection { return $this->promotions; } public function addPromotion(Promotion $promotion): self { if (!$this->promotions->contains($promotion)) { $this->promotions[] = $promotion; $promotion->setRegion($this); } return $this; } public function removePromotion(Promotion $promotion): self { if ($this->promotions->removeElement($promotion)) { // set the owning side to null (unless already changed) if ($promotion->getRegion() === $this) { $promotion->setRegion(null); } } return $this; } public function getRegions(): Collection { return $this->regions; } public function addRegion(Region $region): self { if (!$this->regions->contains($region)) { $this->regions[] = $region; $region->setAddressRegion($this); } return $this; } public function removeRegion(Region $region): self { if ($this->regions->removeElement($region)) { // set the owning side to null (unless already changed) if ($region->getAddressRegion() === $this) { $region->setAddressRegion(null); } } return $this; }}