src/CasinoBundle/Entity/BonusCategory.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use App\CmsBundle\Entity\AcronymTrait;
  4. use App\CmsBundle\Entity\PublishedTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use App\CmsBundle\Entity\SlugTrait;
  9. use App\CmsBundle\Entity\IdTrait;
  10. /**
  11.  * BonusCategory
  12.  *
  13.  * @ORM\Table(
  14.  *     name="bonus_category"
  15.  * )
  16.  * @ORM\Entity(
  17.  *     repositoryClass="App\CasinoBundle\Repository\BonusCategoryRepository"
  18.  * )
  19.  * @ORM\Cache(
  20.  *     usage="NONSTRICT_READ_WRITE",
  21.  *     region="one_day"
  22.  * )
  23.  */
  24. class BonusCategory
  25. {
  26.     use IdTrait;
  27.     use NameTrait;
  28.     use SlugTrait;
  29.     use AliasTrait;
  30.     use PublishedTrait;
  31.     use AcronymTrait;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\BonusType", inversedBy="bonusCategories", cascade={"persist"})
  34.      * @ORM\JoinColumn(nullable=true)
  35.      */
  36.     private $bonusType;
  37.     /**
  38.      * @ORM\ManyToMany(
  39.      *     targetEntity="App\CasinoBundle\Entity\NewBonus",
  40.      *     mappedBy="bonusCategories",
  41.      *     cascade={"persist"}
  42.      *     )
  43.      */
  44.     private $newBonuses;
  45.     /**
  46.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Alias", mappedBy="bonusCategory", cascade={"persist"}, orphanRemoval=true)
  47.      */
  48.     private Collection $aliases;
  49.     /**
  50.      * BonusCategory constructor.
  51.      */
  52.     public function __construct()
  53.     {
  54.         $this->newBonuses = new ArrayCollection();
  55.         $this->aliases = new ArrayCollection();
  56.     }
  57.     /**
  58.      * @return string
  59.      */
  60.     public function __toString()
  61.     {
  62.         return $this->name;
  63.     }
  64.     /**
  65.      * @return Collection|Bonus[]
  66.      */
  67.     public function getNewBonuses(): Collection
  68.     {
  69.         return $this->newBonuses;
  70.     }
  71.     /**
  72.      * @param NewBonus $newBonus
  73.      * @return $this
  74.      */
  75.     public function addNewBonus(NewBonus $newBonus): self
  76.     {
  77.         if (!$this->newBonuses->contains($newBonus)) {
  78.             $this->newBonuses[] = $newBonus;
  79.             $newBonus->addBonusCategory($this);
  80.         }
  81.         return $this;
  82.     }
  83.     /**
  84.      * @param NewBonus $newBonus
  85.      * @return $this
  86.      */
  87.     public function removeNewBonus(NewBonus $newBonus): self
  88.     {
  89.         if ($this->newBonuses->contains($newBonus)) {
  90.             $this->newBonuses->removeElement($newBonus);
  91.             $newBonus->removeBonusCategory($this);
  92.         }
  93.         return $this;
  94.     }
  95.     /**
  96.      * @return BonusType|null
  97.      */
  98.     public function getBonusType(): ?BonusType
  99.     {
  100.         return $this->bonusType;
  101.     }
  102.     /**
  103.      * @param BonusType|null $bonusType
  104.      * @return $this
  105.      */
  106.     public function setBonusType(?BonusType $bonusType): self
  107.     {
  108.         $this->bonusType $bonusType;
  109.         return $this;
  110.     }
  111. }