Place.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Entity\Place;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\ApiResource;
  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\AddressPostal;
  11. use App\Entity\Core\ContactPoint;
  12. use App\Entity\Core\Tagg;
  13. use App\Entity\Organization\Organization;
  14. use App\Entity\Product\Equipment;
  15. //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  16. use Doctrine\Common\Collections\ArrayCollection;
  17. use Doctrine\Common\Collections\Collection;
  18. use Doctrine\ORM\Mapping as ORM;
  19. /**
  20. * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table Place, et supprimer l'attribut discr.
  21. *
  22. * Classe ... qui ...
  23. */
  24. #[ApiResource(operations: [])]
  25. //#[Auditable]
  26. #[ORM\Entity]
  27. #[ORM\Table(name: 'Place')]
  28. #[ORM\InheritanceType('SINGLE_TABLE')]
  29. #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
  30. #[ORM\DiscriminatorMap([
  31. 'place' => 'Place',
  32. 'place_system' => 'PlaceSystem'
  33. ])]
  34. class Place
  35. {
  36. #[ORM\Id]
  37. #[ORM\Column]
  38. #[ORM\GeneratedValue]
  39. private ?int $id = null;
  40. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'places')]
  41. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  42. private AddressPostal $addressPostal;
  43. #[ORM\OneToMany(mappedBy: 'place', targetEntity: Event::class)]
  44. private Collection $events;
  45. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'places', cascade: ['persist'])]
  46. #[ORM\JoinTable(name: 'tag_place')]
  47. #[ORM\JoinColumn(name: 'place_id', referencedColumnName: 'id')]
  48. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  49. private Collection $tags;
  50. #[ORM\ManyToOne(inversedBy: 'places')]
  51. private Organization $organization;
  52. #[ORM\ManyToMany(targetEntity: ContactPoint::class, inversedBy: 'place', cascade: ['persist'])]
  53. private Collection $contactpoint;
  54. #[ORM\OneToMany(mappedBy: 'place', targetEntity: Room::class, cascade: ['persist'], orphanRemoval: true)]
  55. #[ORM\JoinColumn(nullable: false)]
  56. private Collection $rooms;
  57. #[ORM\OneToMany(mappedBy: 'place', targetEntity: PlaceControl::class, cascade: ['persist'], orphanRemoval: true)]
  58. #[ORM\JoinColumn(nullable: false)]
  59. private Collection $controls;
  60. #[ORM\OneToMany(mappedBy: 'place', targetEntity: PlaceRepair::class, cascade: ['persist'], orphanRemoval: true)]
  61. #[ORM\JoinColumn(nullable: false)]
  62. private Collection $repairs;
  63. #[ORM\OneToMany(mappedBy: 'place', targetEntity: Course::class)]
  64. private Collection $courses;
  65. #[ORM\OneToMany(mappedBy: 'place', targetEntity: EducationalProject::class)]
  66. private Collection $educationalProjects;
  67. #[ORM\OneToMany(mappedBy: 'place', targetEntity: Examen::class)]
  68. private Collection $examens;
  69. #[ORM\OneToMany(mappedBy: 'placeStorage', targetEntity: Equipment::class)]
  70. private Collection $equipmentStorages;
  71. #[ORM\OneToMany(mappedBy: 'placeWhereIsUsed', targetEntity: Equipment::class)]
  72. private Collection $equipmentUseds;
  73. public function __construct()
  74. {
  75. $this->events = new ArrayCollection();
  76. $this->tags = new ArrayCollection();
  77. $this->contactpoint = new ArrayCollection();
  78. $this->rooms = new ArrayCollection();
  79. $this->controls = new ArrayCollection();
  80. $this->repairs = new ArrayCollection();
  81. $this->courses = new ArrayCollection();
  82. $this->educationalProjects = new ArrayCollection();
  83. $this->examens = new ArrayCollection();
  84. $this->equipmentStorages = new ArrayCollection();
  85. $this->equipmentUseds = new ArrayCollection();
  86. }
  87. public function getId(): ?int
  88. {
  89. return $this->id;
  90. }
  91. public function getAddressPostal(): ?AddressPostal
  92. {
  93. return $this->addressPostal;
  94. }
  95. public function setAddressPostal(?AddressPostal $addressPostal): self
  96. {
  97. $this->addressPostal = $addressPostal;
  98. return $this;
  99. }
  100. /**
  101. * @return Collection<int, Event>
  102. */
  103. public function getEvents(): Collection
  104. {
  105. return $this->events;
  106. }
  107. public function addEvent(Event $event): self
  108. {
  109. if (!$this->events->contains($event)) {
  110. $this->events[] = $event;
  111. $event->setPlace($this);
  112. }
  113. return $this;
  114. }
  115. public function removeEvent(Event $event): self
  116. {
  117. if ($this->events->removeElement($event)) {
  118. // set the owning side to null (unless already changed)
  119. if ($event->getPlace() === $this) {
  120. $event->setPlace(null);
  121. }
  122. }
  123. return $this;
  124. }
  125. /**
  126. * @return Collection<int, Tagg>
  127. */
  128. public function getTags(): Collection
  129. {
  130. return $this->tags;
  131. }
  132. public function addTag(Tagg $tag): self
  133. {
  134. if (!$this->tags->contains($tag)) {
  135. $this->tags[] = $tag;
  136. }
  137. return $this;
  138. }
  139. public function removeTag(Tagg $tag): self
  140. {
  141. $this->tags->removeElement($tag);
  142. return $this;
  143. }
  144. public function getOrganization(): ?Organization
  145. {
  146. return $this->organization;
  147. }
  148. public function setOrganization(?Organization $organization): self
  149. {
  150. $this->organization = $organization;
  151. return $this;
  152. }
  153. /**
  154. * @return Collection<int, ContactPoint>
  155. */
  156. public function getContactpoint(): Collection
  157. {
  158. return $this->contactpoint;
  159. }
  160. public function addContactpoint(ContactPoint $contactpoint): self
  161. {
  162. if (!$this->contactpoint->contains($contactpoint)) {
  163. $this->contactpoint[] = $contactpoint;
  164. }
  165. return $this;
  166. }
  167. public function removeContactpoint(ContactPoint $contactpoint): self
  168. {
  169. $this->contactpoint->removeElement($contactpoint);
  170. return $this;
  171. }
  172. /**
  173. * @return Collection<int, Room>
  174. */
  175. public function getRooms(): Collection
  176. {
  177. return $this->rooms;
  178. }
  179. public function addRoom(Room $room): self
  180. {
  181. if (!$this->rooms->contains($room)) {
  182. $this->rooms[] = $room;
  183. $room->setPlace($this);
  184. }
  185. return $this;
  186. }
  187. public function removeRoom(Room $room): self
  188. {
  189. if ($this->rooms->removeElement($room)) {
  190. // set the owning side to null (unless already changed)
  191. if ($room->getPlace() === $this) {
  192. $room->setPlace(null);
  193. }
  194. }
  195. return $this;
  196. }
  197. /**
  198. * @return Collection<int, PlaceControl>
  199. */
  200. public function getControls(): Collection
  201. {
  202. return $this->controls;
  203. }
  204. public function addControl(PlaceControl $control): self
  205. {
  206. if (!$this->controls->contains($control)) {
  207. $this->controls[] = $control;
  208. $control->setPlace($this);
  209. }
  210. return $this;
  211. }
  212. public function removeControl(PlaceControl $control): self
  213. {
  214. if ($this->controls->removeElement($control)) {
  215. // set the owning side to null (unless already changed)
  216. if ($control->getPlace() === $this) {
  217. $control->setPlace(null);
  218. }
  219. }
  220. return $this;
  221. }
  222. /**
  223. * @return Collection<int, PlaceRepair>
  224. */
  225. public function getRepairs(): Collection
  226. {
  227. return $this->repairs;
  228. }
  229. public function addRepair(PlaceRepair $repair): self
  230. {
  231. if (!$this->repairs->contains($repair)) {
  232. $this->repairs[] = $repair;
  233. $repair->setPlace($this);
  234. }
  235. return $this;
  236. }
  237. public function removeRepair(PlaceRepair $repair): self
  238. {
  239. if ($this->repairs->removeElement($repair)) {
  240. // set the owning side to null (unless already changed)
  241. if ($repair->getPlace() === $this) {
  242. $repair->setPlace(null);
  243. }
  244. }
  245. return $this;
  246. }
  247. /**
  248. * @return Collection<int, Course>
  249. */
  250. public function getCourses(): Collection
  251. {
  252. return $this->courses;
  253. }
  254. public function addCourse(Course $course): self
  255. {
  256. if (!$this->courses->contains($course)) {
  257. $this->courses[] = $course;
  258. $course->setPlace($this);
  259. }
  260. return $this;
  261. }
  262. public function removeCourse(Course $course): self
  263. {
  264. if ($this->courses->removeElement($course)) {
  265. // set the owning side to null (unless already changed)
  266. if ($course->getPlace() === $this) {
  267. $course->setPlace(null);
  268. }
  269. }
  270. return $this;
  271. }
  272. /**
  273. * @return Collection<int, EducationalProject>
  274. */
  275. public function getEducationalProjects(): Collection
  276. {
  277. return $this->educationalProjects;
  278. }
  279. public function addEducationalProject(EducationalProject $educationalProject): self
  280. {
  281. if (!$this->educationalProjects->contains($educationalProject)) {
  282. $this->educationalProjects[] = $educationalProject;
  283. $educationalProject->setPlace($this);
  284. }
  285. return $this;
  286. }
  287. public function removeEducationalProject(EducationalProject $educationalProject): self
  288. {
  289. if ($this->educationalProjects->removeElement($educationalProject)) {
  290. // set the owning side to null (unless already changed)
  291. if ($educationalProject->getPlace() === $this) {
  292. $educationalProject->setPlace(null);
  293. }
  294. }
  295. return $this;
  296. }
  297. /**
  298. * @return Collection<int, Examen>
  299. */
  300. public function getExamens(): Collection
  301. {
  302. return $this->examens;
  303. }
  304. public function addExamen(Examen $examen): self
  305. {
  306. if (!$this->examens->contains($examen)) {
  307. $this->examens[] = $examen;
  308. $examen->setPlace($this);
  309. }
  310. return $this;
  311. }
  312. public function removeExamen(Examen $examen): self
  313. {
  314. if ($this->examens->removeElement($examen)) {
  315. // set the owning side to null (unless already changed)
  316. if ($examen->getPlace() === $this) {
  317. $examen->setPlace(null);
  318. }
  319. }
  320. return $this;
  321. }
  322. /**
  323. * @return Collection<int, Equipment>
  324. */
  325. public function getEquipmentStorages(): Collection
  326. {
  327. return $this->equipmentStorages;
  328. }
  329. public function addEquipmentStorage(Equipment $equipmentStorage): self
  330. {
  331. if (!$this->equipmentStorages->contains($equipmentStorage)) {
  332. $this->equipmentStorages[] = $equipmentStorage;
  333. $equipmentStorage->setPlaceStorage($this);
  334. }
  335. return $this;
  336. }
  337. public function removeEquipmentStorage(Equipment $equipmentStorage): self
  338. {
  339. if ($this->equipmentStorages->removeElement($equipmentStorage)) {
  340. // set the owning side to null (unless already changed)
  341. if ($equipmentStorage->getPlaceStorage() === $this) {
  342. $equipmentStorage->setPlaceStorage(null);
  343. }
  344. }
  345. return $this;
  346. }
  347. /**
  348. * @return Collection<int, Equipment>
  349. */
  350. public function getEquipmentUseds(): Collection
  351. {
  352. return $this->equipmentUseds;
  353. }
  354. public function addEquipmentUsed(Equipment $equipmentUsed): self
  355. {
  356. if (!$this->equipmentUseds->contains($equipmentUsed)) {
  357. $this->equipmentUseds[] = $equipmentUsed;
  358. $equipmentUsed->setPlaceWhereIsUsed($this);
  359. }
  360. return $this;
  361. }
  362. public function removeEquipmentUsed(Equipment $equipmentUsed): self
  363. {
  364. if ($this->equipmentUseds->removeElement($equipmentUsed)) {
  365. // set the owning side to null (unless already changed)
  366. if ($equipmentUsed->getPlaceWhereIsUsed() === $this) {
  367. $equipmentUsed->setPlaceWhereIsUsed(null);
  368. }
  369. }
  370. return $this;
  371. }
  372. }