src/CasinoBundle/Entity/Language.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use App\CmsBundle\Entity\PublishedTrait;
  4. use App\CmsBundle\Entity\SlugTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\LanguageRepository")
  10.  * @ORM\Table(name="language",
  11.  *     uniqueConstraints={
  12.  *        @ORM\UniqueConstraint(name="language_alpha2_uindex", columns={"alpha2"}),
  13.  *        @ORM\UniqueConstraint(name="language_name_uindex", columns={"name"}),
  14.  *        @ORM\UniqueConstraint(name="language_slug_uindex", columns={"slug"})
  15.  *     },
  16.  *     indexes={
  17.  *          @ORM\Index(name="language_published_index", columns={"published"})
  18.  *     }
  19.  * )
  20.  */
  21. class Language
  22. {
  23.     use SlugTrait;
  24.     use AliasTrait;
  25.     use PublishedTrait;
  26.     /**
  27.      * @ORM\Id()
  28.      * @ORM\GeneratedValue()
  29.      * @ORM\Column(type="integer", options={"unsigned":true})
  30.      */
  31.     private $id;
  32.     /**
  33.      * @var string
  34.      *
  35.      * @ORM\Column(type="string", length=45, unique=true, nullable=false)
  36.      */
  37.     private $alpha2;
  38.     /**
  39.      * @var string
  40.      *
  41.      * @ORM\Column(type="string", length=45, unique=true, nullable=true)
  42.      */
  43.     private $flagCountryAlpha2;
  44.     /**
  45.      * @var string
  46.      * @ORM\Column(type="string", length=90, name="name", nullable=false)
  47.      */
  48.     private $name;
  49.     /**
  50.      * @ORM\ManyToMany(targetEntity="Country", mappedBy="languages")
  51.      */
  52.     private $countries;
  53.     /**
  54.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="languages")
  55.      */
  56.     private $casinos;
  57.     /**
  58.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="chatSupportLanguages")
  59.      */
  60.     private $chatSupportCasinos;
  61.     /**
  62.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="emailSupportLanguages")
  63.      */
  64.     private $emailSupportCasinos;
  65.     /**
  66.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="phoneSupportLanguages")
  67.      */
  68.     private $phoneSupportCasinos;
  69.     /**
  70.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Url", mappedBy="language")
  71.      */
  72.     private $urls;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Alias", mappedBy="language", cascade={"persist"}, orphanRemoval=true)
  75.      */
  76.     private Collection $aliases;
  77.     public function __construct()
  78.     {
  79.         $this->countries = new ArrayCollection();
  80.         $this->chatSupportCasinos = new ArrayCollection();
  81.         $this->phoneSupportCasinos = new ArrayCollection();
  82.         $this->emailSupportCasinos = new ArrayCollection();
  83.         $this->casinos = new ArrayCollection();
  84.         $this->urls = new ArrayCollection();
  85.         $this->aliases = new ArrayCollection();
  86.     }
  87.     /**
  88.      * @return string|null
  89.      */
  90.     public function __toString()
  91.     {
  92.         return $this->getAlpha2();
  93.     }
  94.     /**
  95.      * @return mixed
  96.      */
  97.     public function getId()
  98.     {
  99.         return $this->id;
  100.     }
  101.     /**
  102.      * @param mixed $id
  103.      */
  104.     public function setId(mixed $id): void
  105.     {
  106.         $this->id $id;
  107.     }
  108.     /**
  109.      * @return ?string
  110.      */
  111.     public function getAlpha2(): ?string
  112.     {
  113.         return $this->alpha2;
  114.     }
  115.     /**
  116.      * @param string $alpha2
  117.      */
  118.     public function setAlpha2(string $alpha2): void
  119.     {
  120.         $this->alpha2 $alpha2;
  121.     }
  122.     /**
  123.      * @return string|null
  124.      */
  125.     public function getFlagCountryAlpha2(): ?string
  126.     {
  127.         return $this->flagCountryAlpha2;
  128.     }
  129.     /**
  130.      * @param string|null $flagCountryAlpha2
  131.      */
  132.     public function setFlagCountryAlpha2(?string $flagCountryAlpha2): void
  133.     {
  134.         $this->flagCountryAlpha2 $flagCountryAlpha2;
  135.     }
  136.     /**
  137.      * @return ?string
  138.      */
  139.     public function getName(): ?string
  140.     {
  141.         return $this->name;
  142.     }
  143.     /**
  144.      * @param string $name
  145.      */
  146.     public function setName(string $name): void
  147.     {
  148.         $this->name $name;
  149.     }
  150.     /**
  151.      * @return Collection
  152.      */
  153.     public function getCountries(): Collection
  154.     {
  155.         return $this->countries;
  156.     }
  157.     /**
  158.      * @param Country $country
  159.      * @return $this
  160.      */
  161.     public function addCountries(Country $country): self
  162.     {
  163.         if (!$this->countries->contains($country)) {
  164.             $this->countries[] = $country;
  165.             $country->addLanguage($this);
  166.         }
  167.         return $this;
  168.     }
  169.     /**
  170.      * @param Country $country
  171.      * @return $this
  172.      */
  173.     public function removeCountries(Country $country): self
  174.     {
  175.         if ($this->countries->contains($country)) {
  176.             $this->countries->removeElement($country);
  177.             $country->removeLanguage($this);
  178.         }
  179.         return $this;
  180.     }
  181.     /**
  182.      * @return Collection
  183.      */
  184.     public function getCasinos(): Collection
  185.     {
  186.         return $this->casinos;
  187.     }
  188.     /**
  189.      * @param Casino $casino
  190.      * @return $this
  191.      */
  192.     public function addCasino(Casino $casino): self
  193.     {
  194.         if (!$this->casinos->contains($casino)) {
  195.             $this->casinos[] = $casino;
  196.             $casino->addLanguage($this);
  197.         }
  198.         return $this;
  199.     }
  200.     /**
  201.      * @param Casino $casino
  202.      * @return $this
  203.      */
  204.     public function removeCasino(Casino $casino): self
  205.     {
  206.         if ($this->casinos->contains($casino)) {
  207.             $this->casinos->removeElement($casino);
  208.             $casino->removeLanguage($this);
  209.         }
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection
  214.      */
  215.     public function getUrls(): Collection
  216.     {
  217.         return $this->urls;
  218.     }
  219.     /**
  220.      * @param Url $url
  221.      * @return $this
  222.      */
  223.     public function addUrl(Url $url): self
  224.     {
  225.         if (!$this->urls->contains($url)) {
  226.             $this->urls[] = $url;
  227.             $url->setLanguage($this);
  228.         }
  229.         return $this;
  230.     }
  231.     /**
  232.      * @param Url $url
  233.      * @return $this
  234.      */
  235.     public function removeUrl(Url $url): self
  236.     {
  237.         if ($this->urls->contains($url)) {
  238.             $this->urls->removeElement($url);
  239.             $url->setLanguage(null);
  240.         }
  241.         return $this;
  242.     }
  243. }