Event.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Booking;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Core\Categories;
  6. use App\Entity\Core\File;
  7. use App\Entity\Organization\Organization;
  8. use App\Entity\Place\Place;
  9. use App\Entity\Place\PlaceSystem;
  10. use App\Entity\Place\Room;
  11. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. /**
  17. * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table Event, et supprimer l'attribut discr.
  18. * @todo : migration table tag_booking
  19. *
  20. * Évènement, rencontre
  21. */
  22. #[ApiResource(operations: [])]
  23. // #[Auditable]
  24. #[ORM\Entity]
  25. #[ORM\Table(name: 'Booking')]
  26. class Event extends AbstractBooking
  27. {
  28. #[ORM\ManyToOne(inversedBy: 'events')]
  29. #[ORM\JoinColumn(nullable: false)]
  30. protected Organization $organization;
  31. #[ORM\ManyToOne(inversedBy: 'events')]
  32. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  33. protected ?Place $place;
  34. #[ORM\ManyToOne(inversedBy: 'events')]
  35. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  36. protected ?Room $room = null;
  37. /** @var Collection<int, EventRecur> */
  38. #[ORM\OneToMany(targetEntity: EventRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
  39. protected Collection $eventRecur;
  40. /** @var Collection<int, Event> */
  41. #[ORM\OneToMany(targetEntity: Event::class, mappedBy: 'parent', orphanRemoval: true)]
  42. protected Collection $timeline;
  43. #[ORM\ManyToOne(inversedBy: 'timeline')]
  44. protected ?Event $parent;
  45. #[Assert\Valid]
  46. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'events')]
  47. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  48. protected ?File $image;
  49. #[ORM\ManyToOne]
  50. protected ?EventGender $gender;
  51. /** @var Collection<int, EventUser> */
  52. #[Assert\Valid]
  53. #[ORM\OneToMany(targetEntity: EventUser::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
  54. protected Collection $eventUser;
  55. /** @var Collection<int, Categories> */
  56. #[ORM\ManyToMany(targetEntity: Categories::class, cascade: ['persist'])]
  57. protected Collection $categories;
  58. /** @var Collection<int, EventReport> */
  59. #[ORM\OneToMany(targetEntity: EventReport::class, mappedBy: 'event', orphanRemoval: true)]
  60. protected Collection $eventReports;
  61. /** @var Collection<int, File> */
  62. #[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist'], orphanRemoval: true)]
  63. #[ORM\JoinTable(name: 'event_files')]
  64. #[ORM\JoinColumn(name: 'event_id', referencedColumnName: 'id', onDelete: 'cascade')]
  65. #[ORM\InverseJoinColumn(name: 'file_id', referencedColumnName: 'id', onDelete: 'cascade')]
  66. protected Collection $files;
  67. #[ORM\ManyToOne]
  68. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  69. protected ?PlaceSystem $placeSystem;
  70. /** @var Collection<int, AttendanceBooking> */
  71. #[ORM\OneToMany(targetEntity: AttendanceBooking::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
  72. #[ORM\JoinColumn(nullable: false)]
  73. protected Collection $attendanceBooking;
  74. public function __construct()
  75. {
  76. $this->eventRecur = new ArrayCollection();
  77. $this->timeline = new ArrayCollection();
  78. $this->eventUser = new ArrayCollection();
  79. $this->categories = new ArrayCollection();
  80. $this->eventReports = new ArrayCollection();
  81. $this->files = new ArrayCollection();
  82. $this->attendanceBooking = new ArrayCollection();
  83. $this->organizer = new ArrayCollection();
  84. $this->equipments = new ArrayCollection();
  85. parent::__construct();
  86. }
  87. public function getOrganization(): ?Organization
  88. {
  89. return $this->organization;
  90. }
  91. public function setOrganization(?Organization $organization): self
  92. {
  93. $this->organization = $organization;
  94. return $this;
  95. }
  96. public function getPlace(): ?Place
  97. {
  98. return $this->place;
  99. }
  100. public function setPlace(?Place $place): self
  101. {
  102. $this->place = $place;
  103. return $this;
  104. }
  105. public function getRoom(): ?Room
  106. {
  107. return $this->room;
  108. }
  109. public function setRoom(?Room $room): self
  110. {
  111. $this->room = $room;
  112. return $this;
  113. }
  114. /**
  115. * @return Collection<int, EventRecur>
  116. */
  117. public function getEventRecur(): Collection
  118. {
  119. return $this->eventRecur;
  120. }
  121. public function addEventRecur(EventRecur $eventRecur): self
  122. {
  123. if (!$this->eventRecur->contains($eventRecur)) {
  124. $this->eventRecur[] = $eventRecur;
  125. $eventRecur->setEvent($this);
  126. }
  127. return $this;
  128. }
  129. public function removeEventRecur(EventRecur $eventRecur): self
  130. {
  131. if ($this->eventRecur->removeElement($eventRecur)) {
  132. // set the owning side to null (unless already changed)
  133. if ($eventRecur->getEvent() === $this) {
  134. $eventRecur->setEvent(null);
  135. }
  136. }
  137. return $this;
  138. }
  139. /**
  140. * @return Collection<int, Event>
  141. */
  142. public function getTimeline(): Collection
  143. {
  144. return $this->timeline;
  145. }
  146. public function addTimeline(Event $timeline): self
  147. {
  148. if (!$this->timeline->contains($timeline)) {
  149. $this->timeline[] = $timeline;
  150. $timeline->setParent($this);
  151. }
  152. return $this;
  153. }
  154. public function removeTimeline(Event $timeline): self
  155. {
  156. if ($this->timeline->removeElement($timeline)) {
  157. // set the owning side to null (unless already changed)
  158. if ($timeline->getParent() === $this) {
  159. $timeline->setParent(null);
  160. }
  161. }
  162. return $this;
  163. }
  164. public function getParent(): ?self
  165. {
  166. return $this->parent;
  167. }
  168. public function setParent(?self $parent): self
  169. {
  170. $this->parent = $parent;
  171. return $this;
  172. }
  173. public function getImage(): ?File
  174. {
  175. return $this->image;
  176. }
  177. public function setImage(?File $image): self
  178. {
  179. $this->image = $image;
  180. return $this;
  181. }
  182. public function getGender(): ?EventGender
  183. {
  184. return $this->gender;
  185. }
  186. public function setGender(?EventGender $gender): self
  187. {
  188. $this->gender = $gender;
  189. return $this;
  190. }
  191. /**
  192. * @return Collection<int, EventUser>
  193. */
  194. public function getEventUser(): Collection
  195. {
  196. return $this->eventUser;
  197. }
  198. public function addEventUser(EventUser $eventUser): self
  199. {
  200. if (!$this->eventUser->contains($eventUser)) {
  201. $this->eventUser[] = $eventUser;
  202. $eventUser->setEvent($this);
  203. }
  204. return $this;
  205. }
  206. public function removeEventUser(EventUser $eventUser): self
  207. {
  208. if ($this->eventUser->removeElement($eventUser)) {
  209. // set the owning side to null (unless already changed)
  210. if ($eventUser->getEvent() === $this) {
  211. $eventUser->setEvent(null);
  212. }
  213. }
  214. return $this;
  215. }
  216. /**
  217. * @return Collection<int, Categories>
  218. */
  219. public function getCategories(): Collection
  220. {
  221. return $this->categories;
  222. }
  223. public function addCategory(Categories $category): self
  224. {
  225. if (!$this->categories->contains($category)) {
  226. $this->categories[] = $category;
  227. }
  228. return $this;
  229. }
  230. public function removeCategory(Categories $category): self
  231. {
  232. $this->categories->removeElement($category);
  233. return $this;
  234. }
  235. /**
  236. * @return Collection<int, EventReport>
  237. */
  238. public function getEventReports(): Collection
  239. {
  240. return $this->eventReports;
  241. }
  242. public function addEventReport(EventReport $eventReport): self
  243. {
  244. if (!$this->eventReports->contains($eventReport)) {
  245. $this->eventReports[] = $eventReport;
  246. $eventReport->setEvent($this);
  247. }
  248. return $this;
  249. }
  250. public function removeEventReport(EventReport $eventReport): self
  251. {
  252. if ($this->eventReports->removeElement($eventReport)) {
  253. // set the owning side to null (unless already changed)
  254. if ($eventReport->getEvent() === $this) {
  255. $eventReport->setEvent(null);
  256. }
  257. }
  258. return $this;
  259. }
  260. /**
  261. * @return Collection<int, File>
  262. */
  263. public function getFiles(): Collection
  264. {
  265. return $this->files;
  266. }
  267. public function addFile(File $file): self
  268. {
  269. if (!$this->files->contains($file)) {
  270. $this->files[] = $file;
  271. }
  272. return $this;
  273. }
  274. public function removeFile(File $file): self
  275. {
  276. $this->files->removeElement($file);
  277. return $this;
  278. }
  279. public function getPlaceSystem(): ?PlaceSystem
  280. {
  281. return $this->placeSystem;
  282. }
  283. public function setPlaceSystem(?PlaceSystem $placeSystem): self
  284. {
  285. $this->placeSystem = $placeSystem;
  286. return $this;
  287. }
  288. /**
  289. * @return Collection<int, AttendanceBooking>
  290. */
  291. public function getAttendanceBooking(): Collection
  292. {
  293. return $this->attendanceBooking;
  294. }
  295. public function addAttendanceBooking(AttendanceBooking $attendanceBooking): self
  296. {
  297. if (!$this->attendanceBooking->contains($attendanceBooking)) {
  298. $this->attendanceBooking[] = $attendanceBooking;
  299. $attendanceBooking->setEvent($this);
  300. }
  301. return $this;
  302. }
  303. public function removeAttendanceBooking(AttendanceBooking $attendanceBooking): self
  304. {
  305. if ($this->attendanceBooking->removeElement($attendanceBooking)) {
  306. // set the owning side to null (unless already changed)
  307. if ($attendanceBooking->getEvent() === $this) {
  308. $attendanceBooking->setEvent(null);
  309. }
  310. }
  311. return $this;
  312. }
  313. }