Place.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. <?php
  2. namespace AppBundle\Entity\Place;
  3. use AppBundle\Annotation\DefaultField;
  4. use AppBundle\Entity\Booking\Course;
  5. use AppBundle\Entity\Booking\EducationalProject;
  6. use AppBundle\Entity\Booking\Examen;
  7. use AppBundle\Entity\Core\ContactPoint;
  8. use AppBundle\Entity\Organization\Organization;
  9. use AppBundle\Entity\Product\Equipment;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. /**
  15. * Lieu physique, bâtiment
  16. */
  17. #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Place\Repository\PlaceRepository')]
  18. class Place extends AbstractPlace
  19. {
  20. /**
  21. * @var string A short description of the item.
  22. */
  23. #[Assert\Type(type: 'string')]
  24. #[ORM\Column(type: 'text', nullable: true)]
  25. #[Groups(['place', 'place_list'])]
  26. private $description;
  27. /**
  28. * @var ArrayCollection<OpeningHoursSpecification> The opening hours of a certain place.
  29. */
  30. #[Assert\Valid]
  31. #[ORM\ManyToMany(targetEntity: 'OpeningHoursSpecification', cascade: ['persist'], orphanRemoval: true)]
  32. #[ORM\JoinTable(joinColumns: [], inverseJoinColumns: [])]
  33. #[ORM\JoinColumn(name: 'place_id', referencedColumnName: 'id')]
  34. #[ORM\JoinColumn(name: 'openinghoursspecification_id', referencedColumnName: 'id', unique: true)]
  35. #[Groups(['place_openinghoursspecification'])]
  36. private $openingHoursSpecification;
  37. /**
  38. * @var Organization
  39. *
  40. * @DefaultField()
  41. */
  42. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'places')]
  43. #[Groups(['place'])]
  44. private $organization;
  45. /**
  46. * @var ArrayCollection<ContactPoint>
  47. */
  48. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\ContactPoint', cascade: ['persist'], inversedBy: 'place')]
  49. #[Assert\Valid]
  50. #[Groups(['place_contactpoint', 'place_list'])]
  51. private $contactpoint;
  52. /**
  53. * @var bool
  54. */
  55. #[Assert\Type(type: 'boolean')]
  56. #[Assert\NotNull]
  57. #[ORM\Column(type: 'boolean', options: ['default' => false])]
  58. #[Groups(['place', 'place_list'])]
  59. private $internal = false;
  60. /**
  61. * @var string
  62. */
  63. #[Assert\Type(type: 'string')]
  64. #[Assert\Choice(callback: ['AppBundle\Enum\Place\SiteStatusEnum', 'toArray'])]
  65. #[ORM\Column(type: 'string', nullable: true)]
  66. #[Groups(['place', 'place_list'])]
  67. private $status;
  68. /**
  69. * @var string
  70. */
  71. #[Assert\Type(type: 'string')]
  72. #[Assert\Choice(callback: ['AppBundle\Enum\Place\SiteTypeEnum', 'toArray'])]
  73. #[ORM\Column(type: 'string', nullable: true)]
  74. #[Groups(['place', 'place_list'])]
  75. private $type;
  76. /**
  77. * @var bool
  78. */
  79. #[Assert\Type(type: 'boolean')]
  80. #[Assert\NotNull]
  81. #[ORM\Column(type: 'boolean', options: ['default' => false])]
  82. #[Groups(['place', 'place_list'])]
  83. private $sharing = false;
  84. /**
  85. * @var bool
  86. */
  87. #[Assert\Type(type: 'boolean')]
  88. #[Assert\NotNull]
  89. #[ORM\Column(type: 'boolean', options: ['default' => false])]
  90. #[Groups(['place', 'place_list'])]
  91. private $practice = false;
  92. /**
  93. * @var int
  94. */
  95. #[Assert\Type(type: 'integer', message: 'invalid-integer')]
  96. #[ORM\Column(type: 'integer', nullable: true)]
  97. #[Groups(['place', 'place_list', 'place_reference'])]
  98. private $floorSize;
  99. /**
  100. * @var int
  101. */
  102. #[Assert\Type(type: 'integer', message: 'invalid-integer')]
  103. #[ORM\Column(type: 'integer', nullable: true)]
  104. #[Groups(['place', 'place_list', 'place_reference'])]
  105. private $capacity;
  106. /**
  107. * var ArrayCollection<Room>
  108. */
  109. #[Assert\Valid]
  110. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Place\Room', cascade: ['persist'], mappedBy: 'place', orphanRemoval: true)]
  111. #[ORM\JoinColumn(nullable: false)]
  112. #[Groups(['place_room', 'place_list'])]
  113. private $rooms;
  114. /**
  115. * var ArrayCollection<Control>
  116. */
  117. #[Assert\Valid]
  118. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Place\PlaceControl', cascade: ['persist'], mappedBy: 'place', orphanRemoval: true)]
  119. #[ORM\JoinColumn(nullable: false)]
  120. #[Groups(['place_control'])]
  121. private $controls;
  122. /**
  123. * var ArrayCollection<Repair>
  124. */
  125. #[Assert\Valid]
  126. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Place\PlaceRepair', cascade: ['persist'], mappedBy: 'place', orphanRemoval: true)]
  127. #[ORM\JoinColumn(nullable: false)]
  128. #[Groups(['place_repair'])]
  129. private $repairs;
  130. /**
  131. * @var ArrayCollection<Course>
  132. */
  133. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Course', mappedBy: 'place')]
  134. #[Groups(['place_booking'])]
  135. private $courses;
  136. /**
  137. * @var ArrayCollection<EducationalProject>
  138. */
  139. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\EducationalProject', mappedBy: 'place')]
  140. #[Groups(['place_booking'])]
  141. private $educationalProjects;
  142. /**
  143. * @var ArrayCollection<Examen>
  144. */
  145. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Examen', mappedBy: 'place')]
  146. #[Groups(['place_booking'])]
  147. private $examens;
  148. /**
  149. * @var ArrayCollection<Equipment>
  150. */
  151. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Product\Equipment', mappedBy: 'placeStorage')]
  152. #[Groups(['place_equipment'])]
  153. private $equipmentStorages;
  154. /**
  155. * @var ArrayCollection<Equipment>
  156. */
  157. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Product\Equipment', mappedBy: 'placeWhereIsUsed')]
  158. #[Groups(['place_equipment', 'place_list'])]
  159. private $equipmentUseds;
  160. /**
  161. * @var string
  162. */
  163. #[ORM\Column(type: 'string', length: 14, nullable: true)]
  164. #[Assert\Type(type: 'string')]
  165. #[Groups(['place'])]
  166. private $siretNumber;
  167. public function __construct()
  168. {
  169. $this->openingHoursSpecification = new ArrayCollection();
  170. $this->contactpoint = new ArrayCollection();
  171. $this->rooms = new ArrayCollection();
  172. $this->controls = new ArrayCollection();
  173. $this->repairs = new ArrayCollection();
  174. $this->courses = new ArrayCollection();
  175. $this->educationalProjects = new ArrayCollection();
  176. $this->examens = new ArrayCollection();
  177. $this->equipmentStorages = new ArrayCollection();
  178. $this->equipmentUseds = new ArrayCollection();
  179. }
  180. /**
  181. * Sets description.
  182. *
  183. * @param string $description
  184. *
  185. * @return $this
  186. */
  187. public function setDescription($description)
  188. {
  189. $this->description = $description;
  190. return $this;
  191. }
  192. /**
  193. * Gets description.
  194. *
  195. * @return string
  196. */
  197. public function getDescription()
  198. {
  199. return $this->description;
  200. }
  201. /**
  202. * Adds openingHoursSpecification.
  203. *
  204. * @param OpeningHoursSpecification $openingHoursSpecification
  205. *
  206. * @return $this
  207. */
  208. public function addOpeningHoursSpecification(OpeningHoursSpecification $openingHoursSpecification)
  209. {
  210. $this->openingHoursSpecification[] = $openingHoursSpecification;
  211. return $this;
  212. }
  213. /**
  214. * Removes openingHoursSpecification.
  215. *
  216. * @param OpeningHoursSpecification $openingHoursSpecification
  217. *
  218. * @return $this
  219. */
  220. public function removeOpeningHoursSpecification(OpeningHoursSpecification $openingHoursSpecification)
  221. {
  222. $this->openingHoursSpecification->removeElement($openingHoursSpecification);
  223. return $this;
  224. }
  225. /**
  226. * Gets openingHoursSpecification.
  227. *
  228. * @return ArrayCollection<OpeningHoursSpecification>
  229. */
  230. public function getOpeningHoursSpecification()
  231. {
  232. return $this->openingHoursSpecification;
  233. }
  234. /**
  235. * Sets organization.
  236. *
  237. * @param Organization $organization
  238. *
  239. * @return $this
  240. */
  241. public function setOrganization(Organization $organization = null)
  242. {
  243. $this->organization = $organization;
  244. return $this;
  245. }
  246. /**
  247. * Gets organization.
  248. *
  249. * @return Organization
  250. */
  251. public function getOrganization()
  252. {
  253. return $this->organization;
  254. }
  255. /**
  256. * Adds contactpoint.
  257. *
  258. * @param ContactPoint $contactpoint
  259. *
  260. * @return $this
  261. */
  262. public function addContactpoint(ContactPoint $contactpoint)
  263. {
  264. $this->contactpoint[] = $contactpoint;
  265. return $this;
  266. }
  267. /**
  268. * Removes contactpoint.
  269. *
  270. * @param ContactPoint $contactpoint
  271. *
  272. * @return $this
  273. */
  274. public function removeContactpoint(ContactPoint $contactpoint)
  275. {
  276. $this->contactpoint->removeElement($contactpoint);
  277. return $this;
  278. }
  279. /**
  280. * Gets contactpoint.
  281. *
  282. * @return ArrayCollection<ContactPoint>
  283. */
  284. public function getContactpoint()
  285. {
  286. return $this->contactpoint;
  287. }
  288. /**
  289. * Sets internal.
  290. *
  291. * @param bool $internal
  292. *
  293. * @return $this
  294. */
  295. public function setInternal($internal)
  296. {
  297. $this->internal = $internal;
  298. return $this;
  299. }
  300. /**
  301. * Gets internal.
  302. *
  303. * @return bool
  304. */
  305. public function getInternal()
  306. {
  307. return $this->internal;
  308. }
  309. /**
  310. * Sets status.
  311. *
  312. * @param string $status
  313. *
  314. * @return $this
  315. */
  316. public function setStatus($status)
  317. {
  318. $this->status = $status;
  319. return $this;
  320. }
  321. /**
  322. * Gets status.
  323. *
  324. * @return string
  325. */
  326. public function getStatus()
  327. {
  328. return $this->status;
  329. }
  330. /**
  331. * Sets type.
  332. *
  333. * @param string $type
  334. *
  335. * @return $this
  336. */
  337. public function setType($type)
  338. {
  339. $this->type = $type;
  340. return $this;
  341. }
  342. /**
  343. * Gets type.
  344. *
  345. * @return string
  346. */
  347. public function getType()
  348. {
  349. return $this->type;
  350. }
  351. /**
  352. * Sets sharing.
  353. *
  354. * @param bool $sharing
  355. *
  356. * @return $this
  357. */
  358. public function setSharing($sharing)
  359. {
  360. $this->sharing = $sharing;
  361. return $this;
  362. }
  363. /**
  364. * Gets sharing.
  365. *
  366. * @return bool
  367. */
  368. public function getSharing()
  369. {
  370. return $this->sharing;
  371. }
  372. /**
  373. * Sets practice.
  374. *
  375. * @param bool $practice
  376. *
  377. * @return $this
  378. */
  379. public function setPractice($practice)
  380. {
  381. $this->practice = $practice;
  382. return $this;
  383. }
  384. /**
  385. * Gets practice.
  386. *
  387. * @return bool
  388. */
  389. public function getPractice()
  390. {
  391. return $this->practice;
  392. }
  393. /**
  394. * Sets floorSize.
  395. *
  396. * @param int $floorSize
  397. *
  398. * @return $this
  399. */
  400. public function setFloorSize($floorSize)
  401. {
  402. $this->floorSize = $floorSize;
  403. return $this;
  404. }
  405. /**
  406. * Gets floorSize.
  407. *
  408. * @return int
  409. */
  410. public function getFloorSize()
  411. {
  412. return $this->floorSize;
  413. }
  414. /**
  415. * Sets capacity.
  416. *
  417. * @param int $capacity
  418. *
  419. * @return $this
  420. */
  421. public function setCapacity($capacity)
  422. {
  423. $this->capacity = $capacity;
  424. return $this;
  425. }
  426. /**
  427. * Gets capacity.
  428. *
  429. * @return int
  430. */
  431. public function getCapacity()
  432. {
  433. return $this->capacity;
  434. }
  435. /**
  436. * Adds control.
  437. *
  438. * @param PlaceControl $control
  439. *
  440. * @return $this
  441. */
  442. public function addControl(PlaceControl $control)
  443. {
  444. $control->setPlace($this);
  445. $this->controls[] = $control;
  446. return $this;
  447. }
  448. /**
  449. * Removes control.
  450. *
  451. * @param PlaceControl $control
  452. *
  453. * @return $this
  454. */
  455. public function removeControl(PlaceControl $control)
  456. {
  457. $this->controls->removeElement($control);
  458. return $this;
  459. }
  460. /**
  461. * Gets control.
  462. *
  463. * @return ArrayCollection<PlaceControl>
  464. */
  465. public function getControls()
  466. {
  467. return $this->controls;
  468. }
  469. /**
  470. * Adds repair.
  471. *
  472. * @param PlaceRepair $repair
  473. *
  474. * @return $this
  475. */
  476. public function addRepair(PlaceRepair $repair)
  477. {
  478. $repair->setPlace($this);
  479. $this->repairs[] = $repair;
  480. return $this;
  481. }
  482. /**
  483. * Removes repair.
  484. *
  485. * @param PlaceRepair $repair
  486. *
  487. * @return $this
  488. */
  489. public function removeRepair(PlaceRepair $repair)
  490. {
  491. $this->repairs->removeElement($repair);
  492. return $this;
  493. }
  494. /**
  495. * Gets repairs.
  496. *
  497. * @return ArrayCollection<PlaceRepair>
  498. */
  499. public function getRepairs()
  500. {
  501. return $this->repairs;
  502. }
  503. /**
  504. * Add course
  505. *
  506. * @param \AppBundle\Entity\Booking\Course $course
  507. *
  508. * @return Place
  509. */
  510. public function addCourse(\AppBundle\Entity\Booking\Course $course)
  511. {
  512. $this->courses[] = $course;
  513. return $this;
  514. }
  515. /**
  516. * Remove course
  517. *
  518. * @param \AppBundle\Entity\Booking\Course $course
  519. */
  520. public function removeCourse(\AppBundle\Entity\Booking\Course $course)
  521. {
  522. $this->courses->removeElement($course);
  523. }
  524. /**
  525. * Get courses
  526. *
  527. * @return \Doctrine\Common\Collections\Collection
  528. */
  529. public function getCourses()
  530. {
  531. return $this->courses;
  532. }
  533. /**
  534. * Add educationalProject
  535. *
  536. * @param \AppBundle\Entity\Booking\EducationalProject $educationalProject
  537. *
  538. * @return Place
  539. */
  540. public function addEducationalProject(\AppBundle\Entity\Booking\EducationalProject $educationalProject)
  541. {
  542. $this->educationalProjects[] = $educationalProject;
  543. return $this;
  544. }
  545. /**
  546. * Remove educationalProject
  547. *
  548. * @param \AppBundle\Entity\Booking\EducationalProject $educationalProject
  549. */
  550. public function removeEducationalProject(\AppBundle\Entity\Booking\EducationalProject $educationalProject)
  551. {
  552. $this->educationalProjects->removeElement($educationalProject);
  553. }
  554. /**
  555. * Get educationalProjects
  556. *
  557. * @return \Doctrine\Common\Collections\Collection
  558. */
  559. public function getEducationalProjects()
  560. {
  561. return $this->educationalProjects;
  562. }
  563. /**
  564. * Add examen
  565. *
  566. * @param \AppBundle\Entity\Booking\Examen $examen
  567. *
  568. * @return Place
  569. */
  570. public function addExamen(\AppBundle\Entity\Booking\Examen $examen)
  571. {
  572. $this->examens[] = $examen;
  573. return $this;
  574. }
  575. /**
  576. * Remove examen
  577. *
  578. * @param \AppBundle\Entity\Booking\Examen $examen
  579. */
  580. public function removeExamen(\AppBundle\Entity\Booking\Examen $examen)
  581. {
  582. $this->examens->removeElement($examen);
  583. }
  584. /**
  585. * Get examens
  586. *
  587. * @return \Doctrine\Common\Collections\Collection
  588. */
  589. public function getExamens()
  590. {
  591. return $this->examens;
  592. }
  593. /**
  594. * Add equipmentStorage
  595. *
  596. * @param \AppBundle\Entity\Product\Equipment $equipmentStorage
  597. *
  598. * @return Place
  599. */
  600. public function addEquipmentStorage(\AppBundle\Entity\Product\Equipment $equipmentStorage)
  601. {
  602. $this->equipmentStorages[] = $equipmentStorage;
  603. return $this;
  604. }
  605. /**
  606. * Remove equipmentStorage
  607. *
  608. * @param \AppBundle\Entity\Product\Equipment $equipmentStorage
  609. */
  610. public function removeEquipmentStorage(\AppBundle\Entity\Product\Equipment $equipmentStorage)
  611. {
  612. $this->equipmentStorages->removeElement($equipmentStorage);
  613. }
  614. /**
  615. * Get equipmentStorages
  616. *
  617. * @return \Doctrine\Common\Collections\Collection
  618. */
  619. public function getEquipmentStorages()
  620. {
  621. return $this->equipmentStorages;
  622. }
  623. /**
  624. * Add equipmentUsed
  625. *
  626. * @param \AppBundle\Entity\Product\Equipment $equipmentUsed
  627. *
  628. * @return Place
  629. */
  630. public function addEquipmentUsed(\AppBundle\Entity\Product\Equipment $equipmentUsed)
  631. {
  632. $equipmentUsed->setPlaceWhereIsUsed($this);
  633. $this->equipmentUseds[] = $equipmentUsed;
  634. return $this;
  635. }
  636. /**
  637. * Remove equipmentUsed
  638. *
  639. * @param \AppBundle\Entity\Product\Equipment $equipmentUsed
  640. */
  641. public function removeEquipmentUsed(\AppBundle\Entity\Product\Equipment $equipmentUsed)
  642. {
  643. $equipmentUsed->setPlaceWhereIsUsed(null);
  644. $this->equipmentUseds->removeElement($equipmentUsed);
  645. }
  646. /**
  647. * Get equipmentUseds
  648. *
  649. * @return \Doctrine\Common\Collections\Collection
  650. */
  651. public function getEquipmentUseds()
  652. {
  653. return $this->equipmentUseds;
  654. }
  655. /**
  656. * Sets siretNumber.
  657. *
  658. * @param string $siretNumber
  659. *
  660. * @return $this
  661. */
  662. public function setSiretNumber($siretNumber)
  663. {
  664. $this->siretNumber = $siretNumber;
  665. return $this;
  666. }
  667. /**
  668. * Gets siretNumber.
  669. *
  670. * @return string
  671. */
  672. public function getSiretNumber()
  673. {
  674. return $this->siretNumber;
  675. }
  676. /**
  677. * Add room
  678. *
  679. * @param \AppBundle\Entity\Place\Room $room
  680. *
  681. * @return Place
  682. */
  683. public function addRoom(\AppBundle\Entity\Place\Room $room)
  684. {
  685. $room->setPlace($this);
  686. $this->rooms[] = $room;
  687. return $this;
  688. }
  689. /**
  690. * Remove room
  691. *
  692. * @param \AppBundle\Entity\Place\Room $room
  693. */
  694. public function removeRoom(\AppBundle\Entity\Place\Room $room)
  695. {
  696. $this->rooms->removeElement($room);
  697. }
  698. /**
  699. * Get rooms
  700. *
  701. * @return \Doctrine\Common\Collections\Collection
  702. */
  703. public function getRooms()
  704. {
  705. return $this->rooms;
  706. }
  707. }