OrganizationHoliday.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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\Tagg;
  9. use App\Entity\Organization\Organization;
  10. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  11. use App\Entity\Product\Equipment;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. /**
  16. * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table OrganizationHoliday, et supprimer l'attribut discr.
  17. *
  18. * Périodes de vacances d'une Organization
  19. */
  20. #[ApiResource(operations: [])]
  21. // #[Auditable]
  22. #[ORM\Entity]
  23. class OrganizationHoliday extends AbstractBooking
  24. {
  25. /** @var Collection<int, OrganizationHolidayRecur> */
  26. #[ORM\OneToMany(targetEntity: OrganizationHolidayRecur::class, mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
  27. private Collection $eventRecur;
  28. #[ORM\ManyToOne(inversedBy: 'holidays')]
  29. #[ORM\JoinColumn(nullable: false)]
  30. private Organization $organization;
  31. /** @var Collection<int, Access> */
  32. #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'practicalCourses', cascade: [], orphanRemoval: false)]
  33. #[ORM\JoinTable(name: 'booking_organizer')]
  34. #[ORM\JoinColumn(name: 'booking_id')]
  35. protected Collection $organizer;
  36. /** @var Collection<int, Equipment> */
  37. #[ORM\ManyToMany(targetEntity: Equipment::class, cascade: [], orphanRemoval: false)]
  38. #[ORM\JoinTable(name: 'booking_equipment')]
  39. #[ORM\JoinColumn(name: 'booking_id')]
  40. #[ORM\InverseJoinColumn(name: 'equipment_id')]
  41. protected Collection $equipments;
  42. /** @var Collection<int, Tagg> */
  43. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'bookings', cascade: ['persist'], orphanRemoval: false)]
  44. #[ORM\JoinTable(name: 'tag_booking')]
  45. #[ORM\JoinColumn(name: 'booking_id')]
  46. #[ORM\InverseJoinColumn(name: 'tag_id')]
  47. protected Collection $tags;
  48. public function __construct()
  49. {
  50. $this->eventRecur = new ArrayCollection();
  51. $this->organizer = new ArrayCollection();
  52. $this->equipments = new ArrayCollection();
  53. $this->tags = new ArrayCollection();
  54. }
  55. /**
  56. * @return Collection<int, OrganizationHolidayRecur>
  57. */
  58. public function getEventRecur(): Collection
  59. {
  60. return $this->eventRecur;
  61. }
  62. public function addEventRecur(OrganizationHolidayRecur $eventRecur): self
  63. {
  64. if (!$this->eventRecur->contains($eventRecur)) {
  65. $this->eventRecur[] = $eventRecur;
  66. $eventRecur->setEvent($this);
  67. }
  68. return $this;
  69. }
  70. public function removeEventRecur(OrganizationHolidayRecur $eventRecur): self
  71. {
  72. if ($this->eventRecur->removeElement($eventRecur)) {
  73. // set the owning side to null (unless already changed)
  74. if ($eventRecur->getEvent() === $this) {
  75. $eventRecur->setEvent(null);
  76. }
  77. }
  78. return $this;
  79. }
  80. public function getOrganization(): ?Organization
  81. {
  82. return $this->organization;
  83. }
  84. public function setOrganization(?Organization $organization): self
  85. {
  86. $this->organization = $organization;
  87. return $this;
  88. }
  89. function getOrganizer(): Collection
  90. {
  91. return $this->organizer;
  92. }
  93. function addOrganizer(Access $organizer): self
  94. {
  95. if (!$this->organizer->contains($organizer)) {
  96. $this->organizer[] = $organizer;
  97. $organizer->addPracticalCourse($this);
  98. }
  99. return $this;
  100. }
  101. function removeOrganizer(Access $organizer): self
  102. {
  103. if ($this->organizer->removeElement($organizer)) {
  104. $organizer->removePracticalCourse($this);
  105. }
  106. return $this;
  107. }
  108. function getEquipments(): Collection
  109. {
  110. return $this->equipments;
  111. }
  112. function addEquipment(Equipment $equipment): self
  113. {
  114. if (!$this->equipments->contains($equipment)) {
  115. $this->equipments[] = $equipment;
  116. // $equipment->addXXX($this);
  117. }
  118. return $this;
  119. }
  120. function removeEquipment(Equipment $equipment): self
  121. {
  122. if ($this->equipments->removeElement($equipment)) {
  123. // $equipment->removeXXXX($this);
  124. }
  125. return $this;
  126. }
  127. function getTags(): Collection
  128. {
  129. return $this->tags;
  130. }
  131. function addTag(Tagg $tag): self
  132. {
  133. if (!$this->tags->contains($tag)) {
  134. $this->tags[] = $tag;
  135. $tag->addBooking($this);
  136. }
  137. return $this;
  138. }
  139. function removeTag(Tagg $tag): self
  140. {
  141. if ($this->tags->removeElement($tag)) {
  142. $tag->removeBooking($this);
  143. }
  144. return $this;
  145. }
  146. }