AbstractPlace.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <?php
  2. namespace AppBundle\Entity\Place;
  3. use AppBundle\Entity\Booking\Event;
  4. use AppBundle\Entity\Core\AddressPostal;
  5. use AppBundle\Entity\Core\Tagg;
  6. use AppBundle\Entity\Traits\ContactPointType;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use AppBundle\Entity\Traits\TimestampableEntity;
  12. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  13. use AppBundle\Entity\Core\ContactInterface;
  14. /**
  15. * Description of AbstractBooking
  16. *
  17. * @author sebastienhupin
  18. *
  19. * @see http://schema.org/Booking Documentation on Schema.org
  20. *
  21. *
  22. */
  23. #[ORM\Entity]
  24. #[ORM\Table(name: 'Place')]
  25. #[ORM\InheritanceType('SINGLE_TABLE')]
  26. #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
  27. #[ORM\DiscriminatorMap(['place' => 'Place', 'place_system' => 'PlaceSystem'])]
  28. #[ORM\Entity]
  29. abstract class AbstractPlace implements ContactInterface
  30. {
  31. use TimestampableEntity;
  32. use CreatorUpdaterEntity;
  33. use ContactPointType;
  34. /**
  35. * @var int
  36. */
  37. #[ORM\Column(type: 'integer')]
  38. #[ORM\Id]
  39. #[ORM\GeneratedValue(strategy: 'AUTO')]
  40. #[Groups(['place', 'placesystem', 'equipment_list', 'equipmentcontrol_list_equipment', 'equipmentrepair_list_equipment', 'equipmentaccounting_list', 'equipmentmediatheque_list', 'equipmentcostume_list', 'place_list', 'placecontrol_list', 'placerepair_list', 'examenconvocation_list_examen', 'planning_list', 'event_details', 'examen_details', 'course_details', 'educationalproject_details', 'planning_detail'])]
  41. private $id;
  42. /**
  43. * @var string The name of the item.
  44. */
  45. #[Assert\Type(type: 'string')]
  46. #[ORM\Column(type: 'string', nullable: true)]
  47. #[Groups(['place', 'placesystem', 'place_reference', 'placesystem_reference', 'equipment_list_placestorage', 'equipment_list_placewhereisused', 'equipmentrent_list_equipment', 'equipmentloan_list_equipment', 'equipmentcontrol_list_equipment', 'equipmentrepair_list_equipment', 'equipmentaccounting_list_placewhereisused', 'equipmentmediatheque_list_placewhereisused', 'equipmentmediatheque_list_placestorage', 'equipmentcostume_list_placewhereisused', 'place_list', 'placecontrol_list_place', 'placerepair_list_place', 'examenconvocation_list_examen', 'planning_list', 'event_details_place', 'event_details_placesystem', 'examen_details_place', 'course_details_place', 'educationalproject_details_place', 'reportmessage', 'invitations_list_event', 'planning_detail_place', 'planning_detail_placesystem', 'student_list_courses'])]
  48. private $name;
  49. /**
  50. * @var AddressPostal
  51. */
  52. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Core\AddressPostal', inversedBy: 'places', cascade: ['persist'])]
  53. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  54. #[Assert\Valid]
  55. #[Groups(['place', 'placesystem', 'place_list', 'place_reference', 'placesystem_reference', 'planning_detail_place', 'planning_list', 'planning_detail_placesystem', 'activity_report'])]
  56. private $addressPostal;
  57. /**
  58. * @var ArrayCollection<Event>
  59. */
  60. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Event', mappedBy: 'place')]
  61. #[Groups(['place_booking'])]
  62. private $events;
  63. /**
  64. * @var bool
  65. */
  66. #[Assert\Type(type: 'boolean')]
  67. #[ORM\Column(type: 'boolean', nullable: true, options: ['default' => false])]
  68. #[Groups(['place', 'placesystem', 'place_reference'])]
  69. private $isSystem;
  70. /**
  71. * @var ArrayCollection<Tagg>
  72. */
  73. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'places')]
  74. #[Assert\Valid]
  75. #[ORM\JoinTable(name: 'tag_place', joinColumns: [], inverseJoinColumns: [])]
  76. #[ORM\JoinColumn(name: 'place_id', referencedColumnName: 'id')]
  77. #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  78. #[Groups(['place_tags', 'manage_tags', 'place_list'])]
  79. private $tags;
  80. public function __construct()
  81. {
  82. $this->events = new ArrayCollection();
  83. $this->tags = new ArrayCollection();
  84. }
  85. /**
  86. * Sets id.
  87. *
  88. * @param int $id
  89. *
  90. * @return $this
  91. */
  92. public function setId($id)
  93. {
  94. $this->id = $id;
  95. return $this;
  96. }
  97. /**
  98. * Gets id.
  99. *
  100. * @return int
  101. */
  102. public function getId()
  103. {
  104. return $this->id;
  105. }
  106. /**
  107. * Sets name.
  108. *
  109. * @param string $name
  110. *
  111. * @return $this
  112. */
  113. public function setName($name)
  114. {
  115. $this->name = $name;
  116. return $this;
  117. }
  118. /**
  119. * Gets name.
  120. *
  121. * @return string
  122. */
  123. public function getName()
  124. {
  125. return $this->name;
  126. }
  127. /**
  128. * Sets addressPostal.
  129. *
  130. * @param AddressPostal $addressPostal
  131. *
  132. * @return $this
  133. */
  134. public function setAddressPostal(AddressPostal $addressPostal = null)
  135. {
  136. $this->addressPostal = $addressPostal;
  137. return $this;
  138. }
  139. /**
  140. * Gets addressPostal.
  141. *
  142. * @return AddressPostal
  143. */
  144. public function getAddressPostal()
  145. {
  146. return $this->addressPostal;
  147. }
  148. /**
  149. * Sets isSystem.
  150. *
  151. * @param bool $isSystem
  152. *
  153. * @return $this
  154. */
  155. public function setIsSystem($isSystem)
  156. {
  157. $this->isSystem = $isSystem;
  158. return $this;
  159. }
  160. /**
  161. * Gets isSystem.
  162. *
  163. * @return bool
  164. */
  165. public function getIsSystem()
  166. {
  167. return $this->isSystem;
  168. }
  169. /**
  170. * Add event
  171. *
  172. * @param \AppBundle\Entity\Booking\Event $event
  173. *
  174. * @return Place
  175. */
  176. public function addEvent(\AppBundle\Entity\Booking\Event $event)
  177. {
  178. $this->events[] = $event;
  179. return $this;
  180. }
  181. /**
  182. * Remove event
  183. *
  184. * @param \AppBundle\Entity\Booking\Event $event
  185. */
  186. public function removeEvent(\AppBundle\Entity\Booking\Event $event)
  187. {
  188. $this->events->removeElement($event);
  189. }
  190. /**
  191. * Get events
  192. *
  193. * @return \Doctrine\Common\Collections\Collection
  194. */
  195. public function getEvents()
  196. {
  197. return $this->events;
  198. }
  199. /**
  200. *
  201. * {@inheritdoc}
  202. */
  203. public function getContact()
  204. {
  205. return $this;
  206. }
  207. /**
  208. *
  209. * {@inheritdoc}
  210. */
  211. public function getContactAddress()
  212. {
  213. return $this->getAddressPostal();
  214. }
  215. /**
  216. *
  217. * {@inheritdoc}
  218. */
  219. public function getContactName()
  220. {
  221. return $this->getName();
  222. }
  223. /**
  224. *
  225. * {@inheritdoc}
  226. */
  227. public function getContactContactPoint()
  228. {
  229. return $this->getContactPointPrincipal();
  230. }
  231. /**
  232. * Add tag
  233. *
  234. * @param \AppBundle\Entity\Core\Tagg $tag
  235. *
  236. * @return AbstractPlace
  237. */
  238. public function addTag(\AppBundle\Entity\Core\Tagg $tag)
  239. {
  240. $this->tags[] = $tag;
  241. return $this;
  242. }
  243. /**
  244. * Remove tag
  245. *
  246. * @param \AppBundle\Entity\Core\Tagg $tag
  247. */
  248. public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
  249. {
  250. $this->tags->removeElement($tag);
  251. }
  252. /**
  253. * Get tags
  254. *
  255. * @return \Doctrine\Common\Collections\Collection
  256. */
  257. public function getTags()
  258. {
  259. return $this->tags;
  260. }
  261. }