src/Entity/Game/WordSearch/WordSearchGame.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Game\WordSearch;
  3. use App\Repository\Game\WordSearch\WordSearchGameRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. /**
  9. * @ORM\Entity(repositoryClass=WordSearchGameRepository::class)
  10. */
  11. class WordSearchGame
  12. {
  13. /**
  14. * @ORM\Id
  15. * @ORM\GeneratedValue
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\Column(type="string", length=255)
  21. */
  22. private $title;
  23. /**
  24. * @ORM\OneToMany(targetEntity=WordSearchLevel::class, mappedBy="game")
  25. * @Serializer\Expose
  26. * @Serializer\Groups({"game_details"})
  27. */
  28. private $levels;
  29. /**
  30. * @ORM\Column(type="boolean")
  31. */
  32. private $isPublished = false;
  33. public function __construct()
  34. {
  35. $this->levels = new ArrayCollection();
  36. }
  37. public function getId(): ?int
  38. {
  39. return $this->id;
  40. }
  41. public function getTitle(): ?string
  42. {
  43. return $this->title;
  44. }
  45. public function setTitle(string $title): self
  46. {
  47. $this->title = $title;
  48. return $this;
  49. }
  50. /**
  51. * @return Collection<int, WordSearchLevel>
  52. */
  53. public function getLevels(): Collection
  54. {
  55. return $this->levels;
  56. }
  57. public function addLevel(WordSearchLevel $level): self
  58. {
  59. if (!$this->levels->contains($level)) {
  60. $this->levels[] = $level;
  61. $level->setGame($this);
  62. }
  63. return $this;
  64. }
  65. public function removeLevel(WordSearchLevel $level): self
  66. {
  67. if ($this->levels->removeElement($level)) {
  68. // set the owning side to null (unless already changed)
  69. if ($level->getGame() === $this) {
  70. $level->setGame(null);
  71. }
  72. }
  73. return $this;
  74. }
  75. public function isIsPublished(): ?bool
  76. {
  77. return $this->isPublished;
  78. }
  79. public function setIsPublished(bool $isPublished): self
  80. {
  81. $this->isPublished = $isPublished;
  82. return $this;
  83. }
  84. }