<?php
/**
* @author Leo BANNHOLTZER (contact@scaledev.fr)
* @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
* @license commercial
*/
declare(strict_types=1);
namespace App\Entity;
use Symfony\Component\Uid\Uuid;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\CountryZoneTranslation;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Repository\CountryZoneRepository;
use App\DoctrineExtensions\IsActiveEntity;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
/**
* @ORM\Entity(repositoryClass=CountryZoneRepository::class)
* @Gedmo\TranslationEntity(class="App\Entity\CountryZoneTranslation")
* @ORM\Table(name="country_zone", indexes={
* @ORM\Index(name="name", columns={"name"}),
* @ORM\Index(name="is_active", columns={"is_active"}),
* @ORM\Index(name="deleted_at", columns={"deleted_at"}),
* @ORM\Index(name="created_at", columns={"created_at"}),
* @ORM\Index(name="updated_at", columns={"updated_at"})
* })
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
*/
class CountryZone
{
use UserTimestampableEntity;
use UserSoftDeleteableEntity;
use IsActiveEntity;
/**
* @ORM\Id
* @ORM\Column(type="uuid")
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
*/
private ?Uuid $id = null;
/**
* @Gedmo\Translatable
* @ORM\Column(type="string", length=64)
*/
private string $name;
/**
* @ORM\OneToMany(targetEntity=Country::class, mappedBy="country_zone", fetch="EXTRA_LAZY")
*/
private Collection $countries;
/**
* @ORM\OneToMany(
* targetEntity="CountryZoneTranslation",
* mappedBy="object",
* cascade={"persist", "remove"},
* fetch="EXTRA_LAZY"
* )
*/
private Collection $translations;
public function __construct()
{
$this->countries = new ArrayCollection();
$this->translations = new ArrayCollection();
}
/**
* @return Uuid|null
*/
public function getId(): ?Uuid
{
return $this->id;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return $this
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection|Country[]
*/
public function getCountries(): Collection
{
return $this->countries;
}
/**
* @return Collection|CountryZoneTranslation[]
*/
public function getTranslations()
{
return $this->translations;
}
/**
* @param CountryZoneTranslation $t
* @return $this
*/
public function addTranslation(CountryZoneTranslation $t): self
{
if (!$this->translations->contains($t)) {
$this->translations[] = $t;
$t->setObject($this);
}
return $this;
}
}