src/Flexy/ShopBundle/Entity/Shipping/City.php line 15

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\ShopBundle\Entity\Customer\CustomerAddress;
  5. use App\Flexy\ShopBundle\Entity\Store\Store;
  6. use App\Flexy\ShopBundle\Repository\Shipping\CityRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. #[ApiResource]
  11. #[ORM\Entity(repositoryClassCityRepository::class)]
  12. class City implements \Stringable
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type'integer')]
  17.     private $id;
  18.     #[ORM\Column(type'string'length255)]
  19.     private ?string $name null;
  20.     #[ORM\Column(type'text'nullabletrue)]
  21.     private ?string $description null;
  22.     #[ORM\OneToMany(targetEntityCityRegion::class, mappedBy'city')]
  23.     private \Doctrine\Common\Collections\Collection|array $regions;
  24.     #[ORM\OneToMany(targetEntityDepartement::class, mappedBy'city')]
  25.     private \Doctrine\Common\Collections\Collection|array $departements;
  26.     #[ORM\OneToMany(targetEntityCustomerAddress::class, mappedBy'city')]
  27.     private \Doctrine\Common\Collections\Collection|array $customerAddresses;
  28.     #[ORM\ManyToMany(targetEntityStepType::class, mappedBy'excludeCities')]
  29.     private Collection $stepTypes;
  30.     #[ORM\OneToMany(mappedBy'city'targetEntityStore::class, orphanRemovaltrue)]
  31.     private Collection $stores;
  32.     #[ORM\Column(length255nullabletrue)]
  33.     private ?string $cityCode null;
  34.     #[ORM\Column(nullabletrue)]
  35.     private ?array $metaData = [];
  36.     public function __toString(): string
  37.     {
  38.         return (string) $this->name;
  39.     }
  40.     public function __construct()
  41.     {
  42.         $this->regions = new ArrayCollection();
  43.         $this->departements = new ArrayCollection();
  44.         $this->customerAddresses = new ArrayCollection();
  45.         $this->stepTypes = new ArrayCollection();
  46.         $this->stores = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getName(): ?string
  53.     {
  54.         return $this->name;
  55.     }
  56.     public function setName(string $name): self
  57.     {
  58.         $this->name $name;
  59.         return $this;
  60.     }
  61.     public function getDescription(): ?string
  62.     {
  63.         return $this->description;
  64.     }
  65.     public function setDescription(?string $description): self
  66.     {
  67.         $this->description $description;
  68.         return $this;
  69.     }
  70.     /**
  71.      * @return Collection|CityRegion[]
  72.      */
  73.     public function getRegions(): Collection
  74.     {
  75.         return $this->regions;
  76.     }
  77.     public function addRegion(CityRegion $region): self
  78.     {
  79.         if (!$this->regions->contains($region)) {
  80.             $this->regions[] = $region;
  81.             $region->setCity($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeRegion(CityRegion $region): self
  86.     {
  87.         if ($this->regions->removeElement($region)) {
  88.             // set the owning side to null (unless already changed)
  89.             if ($region->getCity() === $this) {
  90.                 $region->setCity(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95.     /**
  96.      * @return Collection|Departement[]
  97.      */
  98.     public function getDepartements(): Collection
  99.     {
  100.         return $this->departements;
  101.     }
  102.     public function addDepartement(Departement $departement): self
  103.     {
  104.         if (!$this->departements->contains($departement)) {
  105.             $this->departements[] = $departement;
  106.             $departement->setCity($this);
  107.         }
  108.         return $this;
  109.     }
  110.     public function removeDepartement(Departement $departement): self
  111.     {
  112.         if ($this->departements->removeElement($departement)) {
  113.             // set the owning side to null (unless already changed)
  114.             if ($departement->getCity() === $this) {
  115.                 $departement->setCity(null);
  116.             }
  117.         }
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Collection<int, CustomerAddress>
  122.      */
  123.     public function getCustomerAddresses(): Collection
  124.     {
  125.         return $this->customerAddresses;
  126.     }
  127.     public function addCustomerAddress(CustomerAddress $customerAddress): self
  128.     {
  129.         if (!$this->customerAddresses->contains($customerAddress)) {
  130.             $this->customerAddresses[] = $customerAddress;
  131.             $customerAddress->setCity($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeCustomerAddress(CustomerAddress $customerAddress): self
  136.     {
  137.         if ($this->customerAddresses->removeElement($customerAddress)) {
  138.             // set the owning side to null (unless already changed)
  139.             if ($customerAddress->getCity() === $this) {
  140.                 $customerAddress->setCity(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145.     /**
  146.      * @return Collection<int, StepType>
  147.      */
  148.     public function getStepTypes(): Collection
  149.     {
  150.         return $this->stepTypes;
  151.     }
  152.     public function addStepType(StepType $stepType): self
  153.     {
  154.         if (!$this->stepTypes->contains($stepType)) {
  155.             $this->stepTypes->add($stepType);
  156.             $stepType->addExcludeCity($this);
  157.         }
  158.         return $this;
  159.     }
  160.     public function removeStepType(StepType $stepType): self
  161.     {
  162.         if ($this->stepTypes->removeElement($stepType)) {
  163.             $stepType->removeExcludeCity($this);
  164.         }
  165.         return $this;
  166.     }
  167.     /**
  168.      * @return Collection<int, Store>
  169.      */
  170.     public function getStores(): Collection
  171.     {
  172.         return $this->stores;
  173.     }
  174.     public function addStore(Store $store): self
  175.     {
  176.         if (!$this->stores->contains($store)) {
  177.             $this->stores->add($store);
  178.             $store->setCity($this);
  179.         }
  180.         return $this;
  181.     }
  182.     public function removeStore(Store $store): self
  183.     {
  184.         if ($this->stores->removeElement($store)) {
  185.             // set the owning side to null (unless already changed)
  186.             if ($store->getCity() === $this) {
  187.                 $store->setCity(null);
  188.             }
  189.         }
  190.         return $this;
  191.     }
  192.     public function getCityCode(): ?string
  193.     {
  194.         return $this->cityCode;
  195.     }
  196.     public function setCityCode(?string $cityCode): static
  197.     {
  198.         $this->cityCode $cityCode;
  199.         return $this;
  200.     }
  201.     public function getMetaData(): ?array
  202.     {
  203.         return $this->metaData;
  204.     }
  205.     public function setMetaData(?array $metaData): static
  206.     {
  207.         $this->metaData $metaData;
  208.         return $this;
  209.     }
  210. }