src/CasinoBundle/Entity/SlotTag.php line 27

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\ORM\Mapping as ORM;
  7. /**
  8.  * SlotTag
  9.  *
  10.  * @ORM\Table(
  11.  *     name="slot_tag",
  12.  *     indexes={
  13.  *         @ORM\Index(name="slot_tag_published_index", columns={"published"})
  14.  *     },
  15.  *     uniqueConstraints={
  16.  *         @ORM\UniqueConstraint(name="slot_tag_slug_uindex", columns={"slug"}),
  17.  *         @ORM\UniqueConstraint(name="slot_tag_name_uindex", columns={"name"})
  18.  *     }
  19.  * )
  20.  * @ORM\Entity()
  21.  * @ORM\HasLifecycleCallbacks()
  22.  * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="one_day")
  23.  */
  24. class SlotTag
  25. {
  26.     use SlugTrait;
  27.     use PublishedTrait;
  28.     /**
  29.      * @ORM\Id()
  30.      * @ORM\GeneratedValue()
  31.      * @ORM\Column(type="integer")
  32.      */
  33.     private $id;
  34.     /**
  35.      * @ORM\Column(type="string", length=255)
  36.      */
  37.     private $name;
  38.     /**
  39.      * @ORM\Column(type="integer", nullable=true)
  40.      */
  41.     private $type;
  42.     /**
  43.      * @ORM\ManyToMany(targetEntity="Slot", mappedBy="slotTags", cascade={"persist"})
  44.      */
  45.     private $slots;
  46.     public function __construct()
  47.     {
  48.         $this->slots = new ArrayCollection();
  49.     }
  50.     public function __toString(): string
  51.     {
  52.         return $this->name;
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getName(): string
  59.     {
  60.         return $this->name;
  61.     }
  62.     public function setName(string $name): self
  63.     {
  64.         $this->name $name;
  65.         return $this;
  66.     }
  67.     public function getType(): ?int
  68.     {
  69.         return $this->type;
  70.     }
  71.     public function setType(int $type): self
  72.     {
  73.         $this->type $type;
  74.         return $this;
  75.     }
  76.     public function addSlot(Slot $slot): self
  77.     {
  78.         if (!$this->slots->contains($slot)) {
  79.             $this->slots[] = $slot;
  80.             $slot->addSlotTag($this);
  81.         }
  82.         return $this;
  83.     }
  84.     public function removeSlot(Slot $slot): self
  85.     {
  86.         if ($this->slots->contains($slot)) {
  87.             $this->slots->removeElement($slot);
  88.             $slot->removeSlotTag($this);
  89.         }
  90.         return $this;
  91.     }
  92. }