Examen.php 9.0 KB

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