Examen.php 9.0 KB

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