src/Entity/Game/Riddle/ImageRiddle.php line 23

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