src/CasinoBundle/Entity/GameType.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 App\CmsBundle\Entity\TimeStampedTrait;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * GameType
  11.  *
  12.  * @ORM\Table(
  13.  *     name="game_type",
  14.  *     indexes={
  15.  *         @ORM\Index(name="game_type_published_index", columns={"published"}),
  16.  *     },
  17.  *     uniqueConstraints={
  18.  *        @ORM\UniqueConstraint(name="gametype_slug_uindex", columns={"slug"})
  19.  *    }
  20.  * )
  21.  * @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\GameTypeRepository")
  22.  * @ORM\HasLifecycleCallbacks()
  23.  */
  24. class GameType
  25. {
  26.     use SlugTrait;
  27.     use AliasTrait;
  28.     use PublishedTrait;
  29.     use TimeStampedTrait;
  30.     /**
  31.      * @var int
  32.      *
  33.      * @ORM\Column(name="id", type="integer", nullable=false)
  34.      * @ORM\Id
  35.      * @ORM\GeneratedValue()
  36.      */
  37.     private $id;
  38.     /**
  39.      * @var string
  40.      *
  41.      * @ORM\Column(name="name", type="string", length=255, nullable=false)
  42.      */
  43.     private $name;
  44.     /**
  45.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Game", mappedBy="gameType", orphanRemoval=true, cascade={"persist", "remove"})
  46.      */
  47.     private $games;
  48.     /**
  49.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Slot", mappedBy="gameType", cascade={"persist"})
  50.      */
  51.     private $slots;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Alias", mappedBy="gameType", cascade={"persist"}, orphanRemoval=true)
  54.      */
  55.     private Collection $aliases;
  56.     public function __construct()
  57.     {
  58.         $this->games = new ArrayCollection();
  59.         $this->slots = new ArrayCollection();
  60.         $this->aliases = new ArrayCollection();
  61.     }
  62.     public function __toString()
  63.     {
  64.         return $this->name;
  65.     }
  66.     /**
  67.      * @return int
  68.      */
  69.     public function getId(): int
  70.     {
  71.         return $this->id;
  72.     }
  73.     /**
  74.      * @param int $id
  75.      * @return $this
  76.      */
  77.     public function setId(int $id): self
  78.     {
  79.         $this->id $id;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return string
  84.      */
  85.     public function getName(): string
  86.     {
  87.         return $this->name;
  88.     }
  89.     /**
  90.      * @param string $name
  91.      * @return $this
  92.      */
  93.     public function setName(string $name): self
  94.     {
  95.         $this->name $name;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection|Game[]
  100.      */
  101.     public function getGames(): Collection
  102.     {
  103.         return $this->games;
  104.     }
  105.     public function addGame(Game $game): self
  106.     {
  107.         if (!$this->games->contains($game)) {
  108.             $this->games[] = $game;
  109.             $game->setGameType($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeGame(Game $game): self
  114.     {
  115.         if ($this->games->contains($game)) {
  116.             $this->games->removeElement($game);
  117.             // set the owning side to null (unless already changed)
  118.             if ($game->getGameType() === $this) {
  119.                 $game->setGameType(null);
  120.             }
  121.         }
  122.         return $this;
  123.     }
  124.     public function getGamesCount(): int
  125.     {
  126.         return $this->games->count();
  127.     }
  128.     /**
  129.      * @return Collection|Slot[]
  130.      */
  131.     public function getSlots(): Collection
  132.     {
  133.         if (!$this->slots) {
  134.             $this->slots = new ArrayCollection();
  135.         }
  136.         return $this->slots;
  137.     }
  138.     public function addSlot(Slot $slot): self
  139.     {
  140.         if (!$this->getSlots()->contains($slot)) {
  141.             $this->slots[] = $slot;
  142.             $slot->setGameType($this);
  143.         }
  144.         return $this;
  145.     }
  146.     public function removeSlot(Slot $slot): self
  147.     {
  148.         if ($this->slots->contains($slot)) {
  149.             $this->slots->removeElement($slot);
  150.             // set the owning side to null (unless already changed)
  151.             if ($slot->getGameType() === $this) {
  152.                 $slot->setGameType(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157. }