Place.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Place;
  4. use ApiPlatform\Metadata\ApiResource;
  5. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  6. use App\Entity\Booking\Course;
  7. use App\Entity\Booking\EducationalProject;
  8. use App\Entity\Booking\Event;
  9. use App\Entity\Booking\Examen;
  10. use App\Entity\Core\ContactPoint;
  11. use App\Entity\Organization\Organization;
  12. use App\Entity\Product\Equipment;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\ORM\Mapping as ORM;
  16. /**
  17. * Lieu physique, bâtiment.
  18. */
  19. // #[Auditable]
  20. #[ApiResource(operations: [])]
  21. #[ORM\Entity]
  22. class Place extends AbstractPlace
  23. {
  24. /** @var Collection<int, Event> */
  25. #[ORM\OneToMany(targetEntity: Event::class, mappedBy: 'place')]
  26. private Collection $events;
  27. #[ORM\ManyToOne(inversedBy: 'places')]
  28. private ?Organization $organization;
  29. /** @var Collection<int, ContactPoint> */
  30. #[ORM\ManyToMany(targetEntity: ContactPoint::class, inversedBy: 'place', cascade: ['persist'])]
  31. #[ORM\JoinTable(name: 'place_contactpoint')]
  32. #[ORM\JoinColumn(name: 'contactPoint_id', referencedColumnName: 'id', unique: true)]
  33. #[ORM\InverseJoinColumn(name: 'place_id', referencedColumnName: 'id')]
  34. private Collection $contactpoint;
  35. /** @var Collection<int, Room> */
  36. #[ORM\OneToMany(targetEntity: Room::class, mappedBy: 'place', cascade: ['persist'], orphanRemoval: true)]
  37. #[ORM\JoinColumn(nullable: false)]
  38. private Collection $rooms;
  39. /** @var Collection<int, PlaceControl> */
  40. #[ORM\OneToMany(targetEntity: PlaceControl::class, mappedBy: 'place', cascade: ['persist'], orphanRemoval: true)]
  41. #[ORM\JoinColumn(nullable: false)]
  42. private Collection $controls;
  43. /** @var Collection<int, PlaceRepair> */
  44. #[ORM\OneToMany(targetEntity: PlaceRepair::class, mappedBy: 'place', cascade: ['persist'], orphanRemoval: true)]
  45. #[ORM\JoinColumn(nullable: false)]
  46. private Collection $repairs;
  47. /** @var Collection<int, Course> */
  48. #[ORM\OneToMany(targetEntity: Course::class, mappedBy: 'place')]
  49. private Collection $courses;
  50. /** @var Collection<int, EducationalProject> */
  51. #[ORM\OneToMany(targetEntity: EducationalProject::class, mappedBy: 'place')]
  52. private Collection $educationalProjects;
  53. /** @var Collection<int, Examen> */
  54. #[ORM\OneToMany(targetEntity: Examen::class, mappedBy: 'place')]
  55. private Collection $examens;
  56. /** @var Collection<int, Equipment> */
  57. #[ORM\OneToMany(targetEntity: Equipment::class, mappedBy: 'placeStorage')]
  58. private Collection $equipmentStorages;
  59. /** @var Collection<int, Equipment> */
  60. #[ORM\OneToMany(targetEntity: Equipment::class, mappedBy: 'placeWhereIsUsed')]
  61. private Collection $equipmentUseds;
  62. public function __construct()
  63. {
  64. $this->events = new ArrayCollection();
  65. $this->contactpoint = new ArrayCollection();
  66. $this->rooms = new ArrayCollection();
  67. $this->controls = new ArrayCollection();
  68. $this->repairs = new ArrayCollection();
  69. $this->courses = new ArrayCollection();
  70. $this->educationalProjects = new ArrayCollection();
  71. $this->examens = new ArrayCollection();
  72. $this->equipmentStorages = new ArrayCollection();
  73. $this->equipmentUseds = new ArrayCollection();
  74. parent::__construct();
  75. }
  76. public function getEvents(): Collection
  77. {
  78. return $this->events;
  79. }
  80. public function addEvent(Event $event): self
  81. {
  82. if (!$this->events->contains($event)) {
  83. $this->events[] = $event;
  84. $event->setPlace($this);
  85. }
  86. return $this;
  87. }
  88. public function removeEvent(Event $event): self
  89. {
  90. if ($this->events->removeElement($event)) {
  91. // set the owning side to null (unless already changed)
  92. if ($event->getPlace() === $this) {
  93. $event->setPlace(null);
  94. }
  95. }
  96. return $this;
  97. }
  98. public function getOrganization(): ?Organization
  99. {
  100. return $this->organization;
  101. }
  102. public function setOrganization(?Organization $organization): self
  103. {
  104. $this->organization = $organization;
  105. return $this;
  106. }
  107. /**
  108. * @return Collection<int, ContactPoint>
  109. */
  110. public function getContactpoint(): Collection
  111. {
  112. return $this->contactpoint;
  113. }
  114. public function addContactpoint(ContactPoint $contactpoint): self
  115. {
  116. if (!$this->contactpoint->contains($contactpoint)) {
  117. $this->contactpoint[] = $contactpoint;
  118. }
  119. return $this;
  120. }
  121. public function removeContactpoint(ContactPoint $contactpoint): self
  122. {
  123. $this->contactpoint->removeElement($contactpoint);
  124. return $this;
  125. }
  126. /**
  127. * @return Collection<int, Room>
  128. */
  129. public function getRooms(): Collection
  130. {
  131. return $this->rooms;
  132. }
  133. public function addRoom(Room $room): self
  134. {
  135. if (!$this->rooms->contains($room)) {
  136. $this->rooms[] = $room;
  137. $room->setPlace($this);
  138. }
  139. return $this;
  140. }
  141. public function removeRoom(Room $room): self
  142. {
  143. $this->rooms->removeElement($room);
  144. return $this;
  145. }
  146. /**
  147. * @return Collection<int, PlaceControl>
  148. */
  149. public function getControls(): Collection
  150. {
  151. return $this->controls;
  152. }
  153. public function addControl(PlaceControl $control): self
  154. {
  155. if (!$this->controls->contains($control)) {
  156. $this->controls[] = $control;
  157. $control->setPlace($this);
  158. }
  159. return $this;
  160. }
  161. public function removeControl(PlaceControl $control): self
  162. {
  163. if ($this->controls->removeElement($control)) {
  164. // set the owning side to null (unless already changed)
  165. if ($control->getPlace() === $this) {
  166. $control->setPlace(null);
  167. }
  168. }
  169. return $this;
  170. }
  171. /**
  172. * @return Collection<int, PlaceRepair>
  173. */
  174. public function getRepairs(): Collection
  175. {
  176. return $this->repairs;
  177. }
  178. public function addRepair(PlaceRepair $repair): self
  179. {
  180. if (!$this->repairs->contains($repair)) {
  181. $this->repairs[] = $repair;
  182. $repair->setPlace($this);
  183. }
  184. return $this;
  185. }
  186. public function removeRepair(PlaceRepair $repair): self
  187. {
  188. if ($this->repairs->removeElement($repair)) {
  189. // set the owning side to null (unless already changed)
  190. if ($repair->getPlace() === $this) {
  191. $repair->setPlace(null);
  192. }
  193. }
  194. return $this;
  195. }
  196. /**
  197. * @return Collection<int, Course>
  198. */
  199. public function getCourses(): Collection
  200. {
  201. return $this->courses;
  202. }
  203. public function addCourse(Course $course): self
  204. {
  205. if (!$this->courses->contains($course)) {
  206. $this->courses[] = $course;
  207. $course->setPlace($this);
  208. }
  209. return $this;
  210. }
  211. public function removeCourse(Course $course): self
  212. {
  213. if ($this->courses->removeElement($course)) {
  214. // set the owning side to null (unless already changed)
  215. if ($course->getPlace() === $this) {
  216. $course->setPlace(null);
  217. }
  218. }
  219. return $this;
  220. }
  221. /**
  222. * @return Collection<int, EducationalProject>
  223. */
  224. public function getEducationalProjects(): Collection
  225. {
  226. return $this->educationalProjects;
  227. }
  228. public function addEducationalProject(EducationalProject $educationalProject): self
  229. {
  230. if (!$this->educationalProjects->contains($educationalProject)) {
  231. $this->educationalProjects[] = $educationalProject;
  232. $educationalProject->setPlace($this);
  233. }
  234. return $this;
  235. }
  236. public function removeEducationalProject(EducationalProject $educationalProject): self
  237. {
  238. if ($this->educationalProjects->removeElement($educationalProject)) {
  239. // set the owning side to null (unless already changed)
  240. if ($educationalProject->getPlace() === $this) {
  241. $educationalProject->setPlace(null);
  242. }
  243. }
  244. return $this;
  245. }
  246. /**
  247. * @return Collection<int, Examen>
  248. */
  249. public function getExamens(): Collection
  250. {
  251. return $this->examens;
  252. }
  253. public function addExamen(Examen $examen): self
  254. {
  255. if (!$this->examens->contains($examen)) {
  256. $this->examens[] = $examen;
  257. $examen->setPlace($this);
  258. }
  259. return $this;
  260. }
  261. public function removeExamen(Examen $examen): self
  262. {
  263. if ($this->examens->removeElement($examen)) {
  264. // set the owning side to null (unless already changed)
  265. if ($examen->getPlace() === $this) {
  266. $examen->setPlace(null);
  267. }
  268. }
  269. return $this;
  270. }
  271. /**
  272. * @return Collection<int, Equipment>
  273. */
  274. public function getEquipmentStorages(): Collection
  275. {
  276. return $this->equipmentStorages;
  277. }
  278. public function addEquipmentStorage(Equipment $equipmentStorage): self
  279. {
  280. if (!$this->equipmentStorages->contains($equipmentStorage)) {
  281. $this->equipmentStorages[] = $equipmentStorage;
  282. $equipmentStorage->setPlaceStorage($this);
  283. }
  284. return $this;
  285. }
  286. public function removeEquipmentStorage(Equipment $equipmentStorage): self
  287. {
  288. if ($this->equipmentStorages->removeElement($equipmentStorage)) {
  289. // set the owning side to null (unless already changed)
  290. if ($equipmentStorage->getPlaceStorage() === $this) {
  291. $equipmentStorage->setPlaceStorage(null);
  292. }
  293. }
  294. return $this;
  295. }
  296. /**
  297. * @return Collection<int, Equipment>
  298. */
  299. public function getEquipmentUseds(): Collection
  300. {
  301. return $this->equipmentUseds;
  302. }
  303. public function addEquipmentUsed(Equipment $equipmentUsed): self
  304. {
  305. if (!$this->equipmentUseds->contains($equipmentUsed)) {
  306. $this->equipmentUseds[] = $equipmentUsed;
  307. $equipmentUsed->setPlaceWhereIsUsed($this);
  308. }
  309. return $this;
  310. }
  311. public function removeEquipmentUsed(Equipment $equipmentUsed): self
  312. {
  313. if ($this->equipmentUseds->removeElement($equipmentUsed)) {
  314. // set the owning side to null (unless already changed)
  315. if ($equipmentUsed->getPlaceWhereIsUsed() === $this) {
  316. $equipmentUsed->setPlaceWhereIsUsed(null);
  317. }
  318. }
  319. return $this;
  320. }
  321. }