Examen.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Entity\Booking;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use App\Entity\Core\Tagg;
  7. use App\Entity\Education\Education;
  8. use App\Entity\Education\EducationCurriculum;
  9. use App\Entity\Organization\Jury;
  10. use App\Entity\Organization\Organization;
  11. use App\Entity\Place\Place;
  12. use App\Entity\Place\Room;
  13. //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Doctrine\ORM\Mapping as ORM;
  17. /**
  18. * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table Examen, et supprimer l'attribut discr.
  19. * @todo : migration table tag_booking
  20. * Classe ... qui ...
  21. */
  22. #[ApiResource(operations: [])]
  23. //#[Auditable]
  24. #[ORM\Entity]
  25. #[ORM\Table(name: 'Booking')]
  26. class Examen extends AbstractBooking
  27. {
  28. #[ORM\Column(length: 255, nullable: false)]
  29. private string $discr = 'examen';
  30. #[ORM\ManyToOne(inversedBy: 'examens')]
  31. #[ORM\JoinColumn(nullable: false)]
  32. protected Organization $organization;
  33. #[ORM\OneToMany(mappedBy: 'event', targetEntity: ExamenRecur::class, cascade: ['persist'], orphanRemoval: true)]
  34. private Collection $eventRecur;
  35. #[ORM\OneToMany(mappedBy: 'parent', targetEntity: Examen::class, orphanRemoval: true)]
  36. private Collection $timeline;
  37. #[ORM\ManyToOne(inversedBy: 'timeline')]
  38. private Examen $parent;
  39. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'examens')]
  40. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  41. private Jury $jury;
  42. #[ORM\ManyToOne(inversedBy: 'examens')]
  43. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  44. private Education $education;
  45. #[ORM\ManyToMany(targetEntity: EducationCurriculum::class)]
  46. private Collection $educationCurriculum;
  47. #[ORM\OneToMany(mappedBy: 'examen', targetEntity: ExamenConvocation::class, cascade: ['persist'], orphanRemoval: true)]
  48. private Collection $convocation;
  49. #[ORM\OneToMany(mappedBy: 'examen', targetEntity: AttendanceBooking::class, cascade: ['persist'], orphanRemoval: true)]
  50. #[ORM\JoinColumn(nullable: false)]
  51. private Collection $attendanceBooking;
  52. #[ORM\ManyToOne(inversedBy: 'examens')]
  53. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  54. protected Place $place;
  55. #[ORM\ManyToOne(inversedBy: 'examens')]
  56. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  57. protected Room $room;
  58. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'examens', cascade: ['persist'])]
  59. #[ORM\JoinTable(name: 'tag_booking')]
  60. #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
  61. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  62. private Collection $tags;
  63. public function __construct()
  64. {
  65. $this->eventRecur = new ArrayCollection();
  66. $this->timeline = new ArrayCollection();
  67. $this->educationCurriculum = new ArrayCollection();
  68. $this->convocation = new ArrayCollection();
  69. $this->attendanceBooking = new ArrayCollection();
  70. $this->tags = new ArrayCollection();
  71. }
  72. public function getDiscr(): ?string
  73. {
  74. return $this->discr;
  75. }
  76. public function setDiscr(string $discr): self
  77. {
  78. $this->discr = $discr;
  79. return $this;
  80. }
  81. public function getOrganization(): ?Organization
  82. {
  83. return $this->organization;
  84. }
  85. public function setOrganization(?Organization $organization): self
  86. {
  87. $this->organization = $organization;
  88. return $this;
  89. }
  90. /**
  91. * @return Collection<int, ExamenRecur>
  92. */
  93. public function getEventRecur(): Collection
  94. {
  95. return $this->eventRecur;
  96. }
  97. public function addEventRecur(ExamenRecur $eventRecur): self
  98. {
  99. if (!$this->eventRecur->contains($eventRecur)) {
  100. $this->eventRecur[] = $eventRecur;
  101. $eventRecur->setEvent($this);
  102. }
  103. return $this;
  104. }
  105. public function removeEventRecur(ExamenRecur $eventRecur): self
  106. {
  107. if ($this->eventRecur->removeElement($eventRecur)) {
  108. // set the owning side to null (unless already changed)
  109. if ($eventRecur->getEvent() === $this) {
  110. $eventRecur->setEvent(null);
  111. }
  112. }
  113. return $this;
  114. }
  115. /**
  116. * @return Collection<int, Examen>
  117. */
  118. public function getTimeline(): Collection
  119. {
  120. return $this->timeline;
  121. }
  122. public function addTimeline(Examen $timeline): self
  123. {
  124. if (!$this->timeline->contains($timeline)) {
  125. $this->timeline[] = $timeline;
  126. $timeline->setParent($this);
  127. }
  128. return $this;
  129. }
  130. public function removeTimeline(Examen $timeline): self
  131. {
  132. if ($this->timeline->removeElement($timeline)) {
  133. // set the owning side to null (unless already changed)
  134. if ($timeline->getParent() === $this) {
  135. $timeline->setParent(null);
  136. }
  137. }
  138. return $this;
  139. }
  140. public function getParent(): ?self
  141. {
  142. return $this->parent;
  143. }
  144. public function setParent(?self $parent): self
  145. {
  146. $this->parent = $parent;
  147. return $this;
  148. }
  149. public function getJury(): ?Jury
  150. {
  151. return $this->jury;
  152. }
  153. public function setJury(?Jury $jury): self
  154. {
  155. $this->jury = $jury;
  156. return $this;
  157. }
  158. public function getEducation(): ?Education
  159. {
  160. return $this->education;
  161. }
  162. public function setEducation(?Education $education): self
  163. {
  164. $this->education = $education;
  165. return $this;
  166. }
  167. /**
  168. * @return Collection<int, EducationCurriculum>
  169. */
  170. public function getEducationCurriculum(): Collection
  171. {
  172. return $this->educationCurriculum;
  173. }
  174. public function addEducationCurriculum(EducationCurriculum $educationCurriculum): self
  175. {
  176. if (!$this->educationCurriculum->contains($educationCurriculum)) {
  177. $this->educationCurriculum[] = $educationCurriculum;
  178. }
  179. return $this;
  180. }
  181. public function removeEducationCurriculum(EducationCurriculum $educationCurriculum): self
  182. {
  183. $this->educationCurriculum->removeElement($educationCurriculum);
  184. return $this;
  185. }
  186. /**
  187. * @return Collection<int, ExamenConvocation>
  188. */
  189. public function getConvocation(): Collection
  190. {
  191. return $this->convocation;
  192. }
  193. public function addConvocation(ExamenConvocation $convocation): self
  194. {
  195. if (!$this->convocation->contains($convocation)) {
  196. $this->convocation[] = $convocation;
  197. $convocation->setExamen($this);
  198. }
  199. return $this;
  200. }
  201. public function removeConvocation(ExamenConvocation $convocation): self
  202. {
  203. if ($this->convocation->removeElement($convocation)) {
  204. // set the owning side to null (unless already changed)
  205. if ($convocation->getExamen() === $this) {
  206. $convocation->setExamen(null);
  207. }
  208. }
  209. return $this;
  210. }
  211. /**
  212. * @return Collection<int, AttendanceBooking>
  213. */
  214. public function getAttendanceBooking(): Collection
  215. {
  216. return $this->attendanceBooking;
  217. }
  218. public function addAttendanceBooking(AttendanceBooking $attendanceBooking): self
  219. {
  220. if (!$this->attendanceBooking->contains($attendanceBooking)) {
  221. $this->attendanceBooking[] = $attendanceBooking;
  222. $attendanceBooking->setExamen($this);
  223. }
  224. return $this;
  225. }
  226. public function removeAttendanceBooking(AttendanceBooking $attendanceBooking): self
  227. {
  228. if ($this->attendanceBooking->removeElement($attendanceBooking)) {
  229. // set the owning side to null (unless already changed)
  230. if ($attendanceBooking->getExamen() === $this) {
  231. $attendanceBooking->setExamen(null);
  232. }
  233. }
  234. return $this;
  235. }
  236. public function getPlace(): ?Place
  237. {
  238. return $this->place;
  239. }
  240. public function setPlace(?Place $place): self
  241. {
  242. $this->place = $place;
  243. return $this;
  244. }
  245. public function getRoom(): ?Room
  246. {
  247. return $this->room;
  248. }
  249. public function setRoom(?Room $room): self
  250. {
  251. $this->room = $room;
  252. return $this;
  253. }
  254. /**
  255. * @return Collection<int, Tagg>
  256. */
  257. public function getTags(): Collection
  258. {
  259. return $this->tags;
  260. }
  261. public function addTag(Tagg $tag): self
  262. {
  263. if (!$this->tags->contains($tag)) {
  264. $this->tags[] = $tag;
  265. }
  266. return $this;
  267. }
  268. public function removeTag(Tagg $tag): self
  269. {
  270. $this->tags->removeElement($tag);
  271. return $this;
  272. }
  273. }