src/Entity/CountryZone.php line 37

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author Leo BANNHOLTZER (contact@scaledev.fr)
  4.  * @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
  5.  * @license commercial
  6.  */
  7. declare(strict_types=1);
  8. namespace App\Entity;
  9. use Symfony\Component\Uid\Uuid;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use App\Entity\CountryZoneTranslation;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. use App\Repository\CountryZoneRepository;
  14. use App\DoctrineExtensions\IsActiveEntity;
  15. use Doctrine\Common\Collections\Collection;
  16. use Doctrine\Common\Collections\ArrayCollection;
  17. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  18. use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
  19. use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
  20. /**
  21.  * @ORM\Entity(repositoryClass=CountryZoneRepository::class)
  22.  * @Gedmo\TranslationEntity(class="App\Entity\CountryZoneTranslation")
  23.  * @ORM\Table(name="country_zone", indexes={
  24.  *  @ORM\Index(name="name", columns={"name"}),
  25.  *  @ORM\Index(name="is_active", columns={"is_active"}),
  26.  *  @ORM\Index(name="deleted_at", columns={"deleted_at"}),
  27.  *  @ORM\Index(name="created_at", columns={"created_at"}),
  28.  *  @ORM\Index(name="updated_at", columns={"updated_at"})
  29.  * })
  30.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
  31.  */
  32. class CountryZone
  33. {
  34.     use UserTimestampableEntity;
  35.     use UserSoftDeleteableEntity;
  36.     use IsActiveEntity;
  37.     /**
  38.      * @ORM\Id
  39.      * @ORM\Column(type="uuid")
  40.      * @ORM\GeneratedValue(strategy="CUSTOM")
  41.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  42.      */
  43.     private ?Uuid $id null;
  44.     /**
  45.      * @Gedmo\Translatable
  46.      * @ORM\Column(type="string", length=64)
  47.      */
  48.     private string $name;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity=Country::class, mappedBy="country_zone", fetch="EXTRA_LAZY")
  51.      */
  52.     private Collection $countries;
  53.     /**
  54.      * @ORM\OneToMany(
  55.      *   targetEntity="CountryZoneTranslation",
  56.      *   mappedBy="object",
  57.      *   cascade={"persist", "remove"},
  58.      *   fetch="EXTRA_LAZY"
  59.      * )
  60.      */
  61.     private Collection $translations;
  62.     public function __construct()
  63.     {
  64.         $this->countries = new ArrayCollection();
  65.         $this->translations = new ArrayCollection();
  66.     }
  67.     /**
  68.      * @return Uuid|null
  69.      */
  70.     public function getId(): ?Uuid
  71.     {
  72.         return $this->id;
  73.     }
  74.     /**
  75.      * @return string
  76.      */
  77.     public function getName(): string
  78.     {
  79.         return $this->name;
  80.     }
  81.     /**
  82.      * @param string $name
  83.      * @return $this
  84.      */
  85.     public function setName(string $name): self
  86.     {
  87.         $this->name $name;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @return Collection|Country[]
  92.      */
  93.     public function getCountries(): Collection
  94.     {
  95.         return $this->countries;
  96.     }
  97.     /**
  98.      * @return Collection|CountryZoneTranslation[]
  99.      */
  100.     public function getTranslations()
  101.     {
  102.         return $this->translations;
  103.     }
  104.     /**
  105.      * @param CountryZoneTranslation $t
  106.      * @return $this
  107.      */
  108.     public function addTranslation(CountryZoneTranslation $t): self
  109.     {
  110.         if (!$this->translations->contains($t)) {
  111.             $this->translations[] = $t;
  112.             $t->setObject($this);
  113.         }
  114.         return $this;
  115.     }
  116. }