Event.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Booking;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Access\Access;
  6. use App\Entity\Billing\FamilyQuotientBandDetail;
  7. use App\Entity\Billing\ResidenceArea;
  8. use App\Entity\Core\Categories;
  9. use App\Entity\Core\File;
  10. use App\Entity\Core\Tagg;
  11. use App\Entity\Organization\Organization;
  12. use App\Entity\Place\AbstractPlace;
  13. use App\Entity\Place\Place;
  14. use App\Entity\Place\PlaceSystem;
  15. use App\Entity\Place\Room;
  16. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  17. use App\Entity\Product\Equipment;
  18. use Doctrine\Common\Collections\ArrayCollection;
  19. use Doctrine\Common\Collections\Collection;
  20. use Doctrine\ORM\Mapping as ORM;
  21. use Symfony\Component\Validator\Constraints as Assert;
  22. /**
  23. * @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.
  24. * @todo : migration table tag_booking
  25. *
  26. * Évènement, rencontre
  27. */
  28. #[ApiResource(operations: [])]
  29. // #[Auditable]
  30. #[ORM\Entity]
  31. class Event extends AbstractBooking
  32. {
  33. #[ORM\ManyToOne(inversedBy: 'events')]
  34. #[ORM\JoinColumn(nullable: false)]
  35. protected Organization $organization;
  36. #[ORM\ManyToOne(inversedBy: 'events')]
  37. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  38. protected ?Place $place;
  39. #[ORM\ManyToOne(inversedBy: 'events')]
  40. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  41. protected ?Room $room = null;
  42. /** @var Collection<int, EventRecur> */
  43. #[ORM\OneToMany(targetEntity: EventRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
  44. protected Collection $eventRecur;
  45. /** @var Collection<int, Event> */
  46. #[ORM\OneToMany(targetEntity: Event::class, mappedBy: 'parent', orphanRemoval: true)]
  47. protected Collection $timeline;
  48. #[ORM\ManyToOne(inversedBy: 'timeline')]
  49. protected ?Event $parent;
  50. #[Assert\Valid]
  51. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'events')]
  52. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  53. protected ?File $image;
  54. #[ORM\ManyToOne]
  55. protected ?EventGender $gender;
  56. /** @var Collection<int, EventUser> */
  57. #[Assert\Valid]
  58. #[ORM\OneToMany(targetEntity: EventUser::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
  59. protected Collection $eventUser;
  60. /** @var Collection<int, Categories> */
  61. #[ORM\ManyToMany(targetEntity: Categories::class, cascade: ['persist'])]
  62. protected Collection $categories;
  63. /** @var Collection<int, EventReport> */
  64. #[ORM\OneToMany(targetEntity: EventReport::class, mappedBy: 'event', orphanRemoval: true)]
  65. protected Collection $eventReports;
  66. /** @var Collection<int, File> */
  67. #[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist'], orphanRemoval: true)]
  68. #[ORM\JoinTable(name: 'event_files')]
  69. #[ORM\JoinColumn(name: 'event_id', referencedColumnName: 'id', onDelete: 'cascade')]
  70. #[ORM\InverseJoinColumn(name: 'file_id', referencedColumnName: 'id', onDelete: 'cascade')]
  71. protected Collection $files;
  72. #[ORM\ManyToOne]
  73. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  74. protected ?PlaceSystem $placeSystem;
  75. /** @var Collection<int, AttendanceBooking> */
  76. #[ORM\OneToMany(targetEntity: AttendanceBooking::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
  77. #[ORM\JoinColumn(nullable: false)]
  78. protected Collection $attendanceBooking;
  79. /** @var Collection<int, Access> */
  80. #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'eventOrganizers')]
  81. #[ORM\JoinTable(name: 'booking_organizer')]
  82. #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
  83. #[ORM\InverseJoinColumn(name: 'organizer_id', referencedColumnName: 'id')]
  84. protected Collection $organizer;
  85. /** @var Collection<int, Equipment> */
  86. #[ORM\ManyToMany(targetEntity: Equipment::class, cascade: [], orphanRemoval: false)]
  87. #[ORM\JoinTable(name: 'booking_equipment')]
  88. #[ORM\JoinColumn(name: 'booking_id')]
  89. #[ORM\InverseJoinColumn(name: 'equipment_id')]
  90. protected Collection $equipments;
  91. /** @var Collection<int, Tagg> */
  92. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'events', cascade: ['persist'])]
  93. #[ORM\JoinTable(name: 'tag_booking')]
  94. #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
  95. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  96. protected Collection $tags;
  97. public function __construct()
  98. {
  99. $this->eventRecur = new ArrayCollection();
  100. $this->timeline = new ArrayCollection();
  101. $this->eventUser = new ArrayCollection();
  102. $this->categories = new ArrayCollection();
  103. $this->eventReports = new ArrayCollection();
  104. $this->files = new ArrayCollection();
  105. $this->attendanceBooking = new ArrayCollection();
  106. $this->organizer = new ArrayCollection();
  107. $this->tags = new ArrayCollection();
  108. $this->equipments = new ArrayCollection();
  109. }
  110. public function getOrganization(): ?Organization
  111. {
  112. return $this->organization;
  113. }
  114. public function setOrganization(?Organization $organization): self
  115. {
  116. $this->organization = $organization;
  117. return $this;
  118. }
  119. public function getPlace(): ?Place
  120. {
  121. return $this->place;
  122. }
  123. public function setPlace(?Place $place): self
  124. {
  125. $this->place = $place;
  126. return $this;
  127. }
  128. public function getRoom(): ?Room
  129. {
  130. return $this->room;
  131. }
  132. public function setRoom(?Room $room): self
  133. {
  134. $this->room = $room;
  135. return $this;
  136. }
  137. /**
  138. * @return Collection<int, EventRecur>
  139. */
  140. public function getEventRecur(): Collection
  141. {
  142. return $this->eventRecur;
  143. }
  144. public function addEventRecur(EventRecur $eventRecur): self
  145. {
  146. if (!$this->eventRecur->contains($eventRecur)) {
  147. $this->eventRecur[] = $eventRecur;
  148. $eventRecur->setEvent($this);
  149. }
  150. return $this;
  151. }
  152. public function removeEventRecur(EventRecur $eventRecur): self
  153. {
  154. if ($this->eventRecur->removeElement($eventRecur)) {
  155. // set the owning side to null (unless already changed)
  156. if ($eventRecur->getEvent() === $this) {
  157. $eventRecur->setEvent(null);
  158. }
  159. }
  160. return $this;
  161. }
  162. /**
  163. * @return Collection<int, Event>
  164. */
  165. public function getTimeline(): Collection
  166. {
  167. return $this->timeline;
  168. }
  169. public function addTimeline(Event $timeline): self
  170. {
  171. if (!$this->timeline->contains($timeline)) {
  172. $this->timeline[] = $timeline;
  173. $timeline->setParent($this);
  174. }
  175. return $this;
  176. }
  177. public function removeTimeline(Event $timeline): self
  178. {
  179. if ($this->timeline->removeElement($timeline)) {
  180. // set the owning side to null (unless already changed)
  181. if ($timeline->getParent() === $this) {
  182. $timeline->setParent(null);
  183. }
  184. }
  185. return $this;
  186. }
  187. public function getParent(): ?self
  188. {
  189. return $this->parent;
  190. }
  191. public function setParent(?self $parent): self
  192. {
  193. $this->parent = $parent;
  194. return $this;
  195. }
  196. public function getImage(): ?File
  197. {
  198. return $this->image;
  199. }
  200. public function setImage(?File $image): self
  201. {
  202. $this->image = $image;
  203. return $this;
  204. }
  205. public function getGender(): ?EventGender
  206. {
  207. return $this->gender;
  208. }
  209. public function setGender(?EventGender $gender): self
  210. {
  211. $this->gender = $gender;
  212. return $this;
  213. }
  214. /**
  215. * @return Collection<int, EventUser>
  216. */
  217. public function getEventUser(): Collection
  218. {
  219. return $this->eventUser;
  220. }
  221. public function addEventUser(EventUser $eventUser): self
  222. {
  223. if (!$this->eventUser->contains($eventUser)) {
  224. $this->eventUser[] = $eventUser;
  225. $eventUser->setEvent($this);
  226. }
  227. return $this;
  228. }
  229. public function removeEventUser(EventUser $eventUser): self
  230. {
  231. if ($this->eventUser->removeElement($eventUser)) {
  232. // set the owning side to null (unless already changed)
  233. if ($eventUser->getEvent() === $this) {
  234. $eventUser->setEvent(null);
  235. }
  236. }
  237. return $this;
  238. }
  239. /**
  240. * @return Collection<int, Categories>
  241. */
  242. public function getCategories(): Collection
  243. {
  244. return $this->categories;
  245. }
  246. public function addCategory(Categories $category): self
  247. {
  248. if (!$this->categories->contains($category)) {
  249. $this->categories[] = $category;
  250. }
  251. return $this;
  252. }
  253. public function removeCategory(Categories $category): self
  254. {
  255. $this->categories->removeElement($category);
  256. return $this;
  257. }
  258. /**
  259. * @return Collection<int, EventReport>
  260. */
  261. public function getEventReports(): Collection
  262. {
  263. return $this->eventReports;
  264. }
  265. public function addEventReport(EventReport $eventReport): self
  266. {
  267. if (!$this->eventReports->contains($eventReport)) {
  268. $this->eventReports[] = $eventReport;
  269. $eventReport->setEvent($this);
  270. }
  271. return $this;
  272. }
  273. public function removeEventReport(EventReport $eventReport): self
  274. {
  275. if ($this->eventReports->removeElement($eventReport)) {
  276. // set the owning side to null (unless already changed)
  277. if ($eventReport->getEvent() === $this) {
  278. $eventReport->setEvent(null);
  279. }
  280. }
  281. return $this;
  282. }
  283. /**
  284. * @return Collection<int, File>
  285. */
  286. public function getFiles(): Collection
  287. {
  288. return $this->files;
  289. }
  290. public function addFile(File $file): self
  291. {
  292. if (!$this->files->contains($file)) {
  293. $this->files[] = $file;
  294. }
  295. return $this;
  296. }
  297. public function removeFile(File $file): self
  298. {
  299. $this->files->removeElement($file);
  300. return $this;
  301. }
  302. public function getPlaceSystem(): ?PlaceSystem
  303. {
  304. return $this->placeSystem;
  305. }
  306. public function setPlaceSystem(?PlaceSystem $placeSystem): self
  307. {
  308. $this->placeSystem = $placeSystem;
  309. return $this;
  310. }
  311. /**
  312. * @return Collection<int, AttendanceBooking>
  313. */
  314. public function getAttendanceBooking(): Collection
  315. {
  316. return $this->attendanceBooking;
  317. }
  318. public function addAttendanceBooking(AttendanceBooking $attendanceBooking): self
  319. {
  320. if (!$this->attendanceBooking->contains($attendanceBooking)) {
  321. $this->attendanceBooking[] = $attendanceBooking;
  322. $attendanceBooking->setEvent($this);
  323. }
  324. return $this;
  325. }
  326. public function removeAttendanceBooking(AttendanceBooking $attendanceBooking): self
  327. {
  328. if ($this->attendanceBooking->removeElement($attendanceBooking)) {
  329. // set the owning side to null (unless already changed)
  330. if ($attendanceBooking->getEvent() === $this) {
  331. $attendanceBooking->setEvent(null);
  332. }
  333. }
  334. return $this;
  335. }
  336. /**
  337. * @return Collection<int, Access>
  338. */
  339. public function getOrganizer(): Collection
  340. {
  341. return $this->organizer;
  342. }
  343. public function addOrganizer(Access $organizer): self
  344. {
  345. if (!$this->organizer->contains($organizer)) {
  346. $this->organizer[] = $organizer;
  347. }
  348. return $this;
  349. }
  350. public function removeOrganizer(Access $organizer): self
  351. {
  352. $this->organizer->removeElement($organizer);
  353. return $this;
  354. }
  355. /**
  356. * @return Collection<int, Tagg>
  357. */
  358. public function getTags(): Collection
  359. {
  360. return $this->tags;
  361. }
  362. public function addTag(Tagg $tag): self
  363. {
  364. if (!$this->tags->contains($tag)) {
  365. $this->tags[] = $tag;
  366. }
  367. return $this;
  368. }
  369. public function removeTag(Tagg $tag): self
  370. {
  371. $this->tags->removeElement($tag);
  372. return $this;
  373. }
  374. function getEquipments(): Collection
  375. {
  376. return $this->equipments;
  377. }
  378. function addEquipment(Equipment $equipment): self
  379. {
  380. if (!$this->equipments->contains($equipment)) {
  381. $this->equipments[] = $equipment;
  382. // $equipment->addXXX($this);
  383. }
  384. return $this;
  385. }
  386. function removeEquipment(Equipment $equipment): self
  387. {
  388. if ($this->equipments->removeElement($equipment)) {
  389. // $equipment->removeXXXX($this);
  390. }
  391. return $this;
  392. }
  393. }