<?php
namespace App\CasinoBundle\Entity;
use App\CmsBundle\Entity\PublishedTrait;
use App\CmsBundle\Entity\SlugTrait;
use App\CmsBundle\Entity\TimeStampedTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* GameType
*
* @ORM\Table(
* name="game_type",
* indexes={
* @ORM\Index(name="game_type_published_index", columns={"published"}),
* },
* uniqueConstraints={
* @ORM\UniqueConstraint(name="gametype_slug_uindex", columns={"slug"})
* }
* )
* @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\GameTypeRepository")
* @ORM\HasLifecycleCallbacks()
*/
class GameType
{
use SlugTrait;
use AliasTrait;
use PublishedTrait;
use TimeStampedTrait;
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue()
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Game", mappedBy="gameType", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $games;
/**
* @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Slot", mappedBy="gameType", cascade={"persist"})
*/
private $slots;
/**
* @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Alias", mappedBy="gameType", cascade={"persist"}, orphanRemoval=true)
*/
private Collection $aliases;
public function __construct()
{
$this->games = new ArrayCollection();
$this->slots = new ArrayCollection();
$this->aliases = new ArrayCollection();
}
public function __toString()
{
return $this->name;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return $this
*/
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return $this
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection|Game[]
*/
public function getGames(): Collection
{
return $this->games;
}
public function addGame(Game $game): self
{
if (!$this->games->contains($game)) {
$this->games[] = $game;
$game->setGameType($this);
}
return $this;
}
public function removeGame(Game $game): self
{
if ($this->games->contains($game)) {
$this->games->removeElement($game);
// set the owning side to null (unless already changed)
if ($game->getGameType() === $this) {
$game->setGameType(null);
}
}
return $this;
}
public function getGamesCount(): int
{
return $this->games->count();
}
/**
* @return Collection|Slot[]
*/
public function getSlots(): Collection
{
if (!$this->slots) {
$this->slots = new ArrayCollection();
}
return $this->slots;
}
public function addSlot(Slot $slot): self
{
if (!$this->getSlots()->contains($slot)) {
$this->slots[] = $slot;
$slot->setGameType($this);
}
return $this;
}
public function removeSlot(Slot $slot): self
{
if ($this->slots->contains($slot)) {
$this->slots->removeElement($slot);
// set the owning side to null (unless already changed)
if ($slot->getGameType() === $this) {
$slot->setGameType(null);
}
}
return $this;
}
}