src/Entity/Game/Riddle/WordRiddle.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Game\Riddle;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Game\Riddle\WordRiddleParticipation;
  5. use App\Repository\Game\Riddle\WordRiddleRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use JMS\Serializer\Annotation as Serializer;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. /**
  13. * @ORM\Entity(repositoryClass=WordRiddleRepository::class)
  14. * @Serializer\ExclusionPolicy("ALL")
  15. * @UniqueEntity(
  16. * fields={"name"},
  17. * errorPath="name",
  18. * message="Un jeu existe avec le même nom"
  19. * )
  20. */
  21. class WordRiddle extends BaseEntity
  22. {
  23. /**
  24. * @ORM\Id
  25. * @ORM\GeneratedValue
  26. * @ORM\Column(type="integer")
  27. * @Serializer\Expose
  28. * @Serializer\Groups({"word_riddle_list"})
  29. */
  30. private $id;
  31. /**
  32. * @ORM\Column(type="text")
  33. * @Serializer\Expose
  34. * @Serializer\Groups({"word_riddle_list"})
  35. */
  36. private $clue;
  37. /**
  38. * @ORM\Column(type="string", length=255)
  39. * @Serializer\Expose
  40. * @Serializer\Groups({"word_riddle_list"})
  41. */
  42. private $word;
  43. /**
  44. * @ORM\Column(type="integer", nullable=true)
  45. * @Serializer\Expose
  46. * @Serializer\Groups({"word_riddle_list"})
  47. */
  48. private $numberOfAttempts;
  49. /**
  50. * @Gedmo\Slug(fields={"name"})
  51. * @ORM\Column(length=191)
  52. */
  53. private $slug;
  54. /**
  55. * @ORM\Column(type="string", length=255)
  56. * @Serializer\Expose
  57. * @Serializer\Groups({"word_riddle_list"})
  58. */
  59. private $name;
  60. /**
  61. * @ORM\Column(type="boolean")
  62. */
  63. private $isPublished = true;
  64. /**
  65. * @Serializer\Expose
  66. * @Serializer\Groups({"word_riddle_list"})
  67. */
  68. private $letters;
  69. /**
  70. * @ORM\Column(type="integer", nullable=true)
  71. */
  72. private $point = 0;
  73. /**
  74. * @ORM\OneToMany(targetEntity=WordRiddleParticipation::class, mappedBy="wordRiddle", cascade={"remove"})
  75. */
  76. private $wordRiddleParticipations;
  77. public function __construct()
  78. {
  79. $this->wordRiddleParticipations = new ArrayCollection();
  80. }
  81. public function getId(): ?int
  82. {
  83. return $this->id;
  84. }
  85. public function getClue(): ?string
  86. {
  87. return $this->clue;
  88. }
  89. public function setClue(string $clue): self
  90. {
  91. $this->clue = $clue;
  92. return $this;
  93. }
  94. public function getWord(): ?string
  95. {
  96. return $this->word;
  97. }
  98. public function setWord(string $word): self
  99. {
  100. $this->word = $word;
  101. return $this;
  102. }
  103. public function getNumberOfAttempts(): ?int
  104. {
  105. return $this->numberOfAttempts;
  106. }
  107. public function setNumberOfAttempts(?int $numberOfAttempts): self
  108. {
  109. $this->numberOfAttempts = $numberOfAttempts;
  110. return $this;
  111. }
  112. public function getName(): ?string
  113. {
  114. return $this->name;
  115. }
  116. public function setName(string $name): self
  117. {
  118. $this->name = $name;
  119. return $this;
  120. }
  121. /**
  122. * Get the value of slug
  123. */
  124. public function getSlug()
  125. {
  126. return $this->slug;
  127. }
  128. /**
  129. * Set the value of slug
  130. *
  131. * @return self
  132. */
  133. public function setSlug($slug)
  134. {
  135. $this->slug = $slug;
  136. return $this;
  137. }
  138. public function isIsPublished(): ?bool
  139. {
  140. return $this->isPublished;
  141. }
  142. public function setIsPublished(bool $isPublished): self
  143. {
  144. $this->isPublished = $isPublished;
  145. return $this;
  146. }
  147. public function getLetters(): ?array
  148. {
  149. return $this->letters;
  150. }
  151. public function setLetters(?array $letters): self
  152. {
  153. $this->letters = $letters;
  154. return $this;
  155. }
  156. public function getPoint(): ?int
  157. {
  158. return $this->point;
  159. }
  160. public function setPoint(?int $point): self
  161. {
  162. $this->point = $point;
  163. return $this;
  164. }
  165. /**
  166. * @return Collection<int, WordRiddleParticipation>
  167. */
  168. public function getWordRiddleParticipations(): Collection
  169. {
  170. return $this->wordRiddleParticipations;
  171. }
  172. public function addWordRiddleParticipation(WordRiddleParticipation $wordRiddleParticipation): self
  173. {
  174. if (!$this->wordRiddleParticipations->contains($wordRiddleParticipation)) {
  175. $this->wordRiddleParticipations[] = $wordRiddleParticipation;
  176. $wordRiddleParticipation->setWordRiddle($this);
  177. }
  178. return $this;
  179. }
  180. public function removeWordRiddleParticipation(WordRiddleParticipation $wordRiddleParticipation): self
  181. {
  182. if ($this->wordRiddleParticipations->removeElement($wordRiddleParticipation)) {
  183. // set the owning side to null (unless already changed)
  184. if ($wordRiddleParticipation->getWordRiddle() === $this) {
  185. $wordRiddleParticipation->setWordRiddle(null);
  186. }
  187. }
  188. return $this;
  189. }
  190. }