src/CasinoBundle/Entity/CasinoCategory.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use App\CmsBundle\Entity\PublishedTrait;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\CmsBundle\Entity\SlugTrait;
  8. use App\CmsBundle\Entity\IdTrait;
  9. /**
  10.  * CasinoCategory
  11.  *
  12.  * @ORM\Table(
  13.  *     name="casino_category",
  14.  *     indexes={
  15.  *          @ORM\Index(name="casino_category_published_index", columns={"published"})
  16.  *     },
  17.  *     uniqueConstraints={
  18.  *        @ORM\UniqueConstraint(name="casino_category_slug_uindex", columns={"slug"}),
  19.  *        @ORM\UniqueConstraint(name="casino_category_name_uindex", columns={"name"})
  20.  *     }
  21.  * )
  22.  * @ORM\Entity(
  23.  *     repositoryClass="App\CasinoBundle\Repository\CasinoCategoryRepository"
  24.  * )
  25.  * @ORM\Cache(
  26.  *     usage="NONSTRICT_READ_WRITE",
  27.  *     region="one_day"
  28.  * )
  29.  */
  30. class CasinoCategory
  31. {
  32.     use IdTrait;
  33.     use NameTrait;
  34.     use SlugTrait;
  35.     use AliasTrait;
  36.     use PublishedTrait;
  37.     /**
  38.      * @ORM\ManyToMany(
  39.      *     targetEntity="App\CasinoBundle\Entity\Casino",
  40.      *     mappedBy="casinoCategories",
  41.      *     cascade={"persist"}
  42.      *     )
  43.      */
  44.     private $casinos;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private string $acronym;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Alias", mappedBy="casinoCategory", cascade={"persist"}, orphanRemoval=true)
  51.      */
  52.     private Collection $aliases;
  53.     /**
  54.      * CasinoCategory constructor.
  55.      */
  56.     public function __construct()
  57.     {
  58.         $this->casinos = new ArrayCollection();
  59.         $this->aliases = new ArrayCollection();
  60.     }
  61.     /**
  62.      * @return string
  63.      */
  64.     public function __toString()
  65.     {
  66.         return $this->name;
  67.     }
  68.     /**
  69.      * @return Collection|Bonus[]
  70.      */
  71.     public function getCasinos(): Collection
  72.     {
  73.         return $this->casinos;
  74.     }
  75.     /**
  76.      * @param Casino $casino
  77.      * @return $this
  78.      */
  79.     public function addCasino(Casino $casino): self
  80.     {
  81.         if (!$this->casinos->contains($casino)) {
  82.             $this->casinos[] = $casino;
  83.             $casino->addCasinoCategory($this);
  84.         }
  85.         return $this;
  86.     }
  87.     /**
  88.      * @param Casino $casino
  89.      * @return $this
  90.      */
  91.     public function removeCasino(Casino $casino): self
  92.     {
  93.         if ($this->casinos->contains($casino)) {
  94.             $this->casinos->removeElement($casino);
  95.             $casino->removeCasinoCategory($this);
  96.         }
  97.         return $this;
  98.     }
  99.     /**
  100.      * @return string|null
  101.      */
  102.     public function getAcronym(): ?string
  103.     {
  104.         return $this->acronym;
  105.     }
  106.     /**
  107.      * @param string $acronym
  108.      * @return $this
  109.      */
  110.     public function setAcronym(string $acronym): self
  111.     {
  112.         $this->acronym $acronym;
  113.         return $this;
  114.     }
  115. }