src/Entity/Game/WordSearch/Grid.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Game\WordSearch;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\User;
  5. use App\Repository\Game\WordSearch\GridRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use JMS\Serializer\Annotation as Serializer;
  13. /**
  14. * @ORM\Entity(repositoryClass=GridRepository::class)
  15. * @Serializer\ExclusionPolicy("ALL")
  16. * @UniqueEntity(
  17. * fields={"name"},
  18. * errorPath="name",
  19. * message="Un jeu existe avec le même nom"
  20. * )
  21. */
  22. class Grid extends BaseEntity
  23. {
  24. /**
  25. * @ORM\Id
  26. * @ORM\GeneratedValue
  27. * @ORM\Column(type="integer")
  28. * @Serializer\Expose
  29. * @Serializer\Groups({"grid_list"})
  30. */
  31. private $id;
  32. /**
  33. * @ORM\Column(type="integer")
  34. */
  35. private $size;
  36. /**
  37. * @ORM\Column(type="string", length=255)
  38. * @Serializer\Expose
  39. * @Serializer\Groups({"grid_list"})
  40. */
  41. private $name;
  42. /**
  43. * @ORM\Column(type="text", nullable=true)
  44. * @Serializer\Expose
  45. * @Serializer\Groups({"grid_list"})
  46. */
  47. private $description;
  48. /**
  49. * @Gedmo\Slug(fields={"name"})
  50. * @ORM\Column(length=191)
  51. */
  52. private $slug;
  53. /**
  54. * @ORM\Column(type="boolean")
  55. */
  56. private $isPublished = false;
  57. /**
  58. * @ORM\ManyToMany(targetEntity=Word::class, inversedBy="grids", cascade={"remove"})
  59. */
  60. private $words;
  61. /**
  62. * @ORM\Column(type="integer", nullable=true)
  63. */
  64. private $point = 0;
  65. /**
  66. * @ORM\Column(type="time", nullable=true)
  67. */
  68. private $time;
  69. /**
  70. * @ORM\Column(type="datetime", nullable=true)
  71. */
  72. private $endAt;
  73. /**
  74. * @ORM\OneToMany(targetEntity=WordSearchParticipation::class, mappedBy="grid", cascade={"remove"})
  75. */
  76. private $wordSearchParticipations;
  77. /**
  78. * @ORM\Column(type="json", nullable=true)
  79. */
  80. private $layout = [];
  81. public function __construct()
  82. {
  83. $this->words = new ArrayCollection();
  84. $this->wordSearchParticipations = new ArrayCollection();
  85. }
  86. public function getId(): ?int
  87. {
  88. return $this->id;
  89. }
  90. public function getSize(): ?int
  91. {
  92. return $this->size;
  93. }
  94. public function setSize(int $size): self
  95. {
  96. $this->size = $size;
  97. return $this;
  98. }
  99. public function getName(): ?string
  100. {
  101. return $this->name;
  102. }
  103. public function setName(string $name): self
  104. {
  105. $this->name = $name;
  106. return $this;
  107. }
  108. public function getDescription(): ?string
  109. {
  110. return $this->description;
  111. }
  112. public function setDescription(?string $description): self
  113. {
  114. $this->description = $description;
  115. return $this;
  116. }
  117. /**
  118. * Get the value of slug
  119. */
  120. public function getSlug()
  121. {
  122. return $this->slug;
  123. }
  124. /**
  125. * Set the value of slug
  126. *
  127. * @return self
  128. */
  129. public function setSlug($slug)
  130. {
  131. $this->slug = $slug;
  132. return $this;
  133. }
  134. public function isIsPublished(): ?bool
  135. {
  136. return $this->isPublished;
  137. }
  138. public function setIsPublished(bool $isPublished): self
  139. {
  140. $this->isPublished = $isPublished;
  141. return $this;
  142. }
  143. /**
  144. * @return Collection<int, Word>
  145. */
  146. public function getWords(): Collection
  147. {
  148. return $this->words;
  149. }
  150. public function addWord(Word $word): self
  151. {
  152. if (!$this->words->contains($word)) {
  153. $this->words[] = $word;
  154. }
  155. return $this;
  156. }
  157. public function removeWord(Word $word): self
  158. {
  159. $this->words->removeElement($word);
  160. return $this;
  161. }
  162. public function getPoint(): ?int
  163. {
  164. return $this->point;
  165. }
  166. public function setPoint(?int $point): self
  167. {
  168. $this->point = $point;
  169. return $this;
  170. }
  171. public function getTime(): ?\DateTimeInterface
  172. {
  173. return $this->time;
  174. }
  175. public function setTime(?\DateTimeInterface $time): self
  176. {
  177. $this->time = $time;
  178. return $this;
  179. }
  180. public function getEndAt(): ?\DateTimeInterface
  181. {
  182. return $this->endAt;
  183. }
  184. public function setEndAt(?\DateTimeInterface $endAt): self
  185. {
  186. $this->endAt = $endAt;
  187. return $this;
  188. }
  189. /**
  190. * @return Collection<int, WordSearchParticipation>
  191. */
  192. public function getWordSearchParticipations(): Collection
  193. {
  194. return $this->wordSearchParticipations;
  195. }
  196. public function addWordSearchParticipation(WordSearchParticipation $wordSearchParticipation): self
  197. {
  198. if (!$this->wordSearchParticipations->contains($wordSearchParticipation)) {
  199. $this->wordSearchParticipations[] = $wordSearchParticipation;
  200. $wordSearchParticipation->setGrid($this);
  201. }
  202. return $this;
  203. }
  204. public function removeWordSearchParticipation(WordSearchParticipation $wordSearchParticipation): self
  205. {
  206. if ($this->wordSearchParticipations->removeElement($wordSearchParticipation)) {
  207. // set the owning side to null (unless already changed)
  208. if ($wordSearchParticipation->getGrid() === $this) {
  209. $wordSearchParticipation->setGrid(null);
  210. }
  211. }
  212. return $this;
  213. }
  214. public function getLayout(): ?array
  215. {
  216. return $this->layout;
  217. }
  218. public function setLayout(?array $layout): self
  219. {
  220. $this->layout = $layout;
  221. return $this;
  222. }
  223. }