Activity.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <?php
  2. namespace AppBundle\Entity\Organization;
  3. use AppBundle\Annotation\DefaultField;
  4. use AppBundle\Entity\Core\File;
  5. use AppBundle\Entity\Core\Tagg;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Dunglas\ApiBundle\Annotation\Iri;
  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\Annotation\ExportSplitFields;
  14. /**
  15. * Types d'activités proposées par une structure
  16. *
  17. * @Iri("http://schema.org/Activity")
  18. */
  19. #[ORM\Entity]
  20. class Activity
  21. {
  22. use TimestampableEntity;
  23. use CreatorUpdaterEntity;
  24. /**
  25. * @var int
  26. */
  27. #[ORM\Column(type: 'integer')]
  28. #[ORM\Id]
  29. #[ORM\GeneratedValue(strategy: 'AUTO')]
  30. #[Groups(['activity', 'activity_reference', 'access_details_organizationfunction', 'network_list', 'organization_cotisation_steps'])]
  31. private $id;
  32. /**
  33. * @var string A short description of the item.
  34. *
  35. * @Iri("https://schema.org/description")
  36. */
  37. #[ORM\Column(type: 'text', nullable: true)]
  38. #[Assert\Type(type: 'string')]
  39. #[Groups(['activity'])]
  40. private $description;
  41. /**
  42. * @var File An image of the item. This can be a [URL](http://schema.org/URL) or a fully described [ImageObject](http://schema.org/ImageObject).
  43. * @Iri("https://schema.org/logo")
  44. */
  45. #[Assert\Valid]
  46. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Core\File', cascade: ['persist'], inversedBy: 'activityLogos')]
  47. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  48. #[Groups(['activity'])]
  49. private $logo;
  50. /**
  51. * @var File An image of the item. This can be a [URL](http://schema.org/URL) or a fully described [ImageObject](http://schema.org/ImageObject).
  52. * @Iri("https://schema.org/logo")
  53. */
  54. #[Assert\Valid]
  55. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Core\File', cascade: ['persist'], inversedBy: 'activityImages')]
  56. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  57. #[Groups(['activity'])]
  58. private $imageActivity;
  59. /**
  60. * @var string The name of the item.
  61. *
  62. * @Iri("https://schema.org/name")
  63. */
  64. #[ORM\Column(type: 'string', nullable: true)]
  65. #[Assert\Type(type: 'string')]
  66. #[Groups(['activity', 'activity_reference', 'access_detail_personactivity', 'student_list_personactivity', 'adherent_list_personactivity', 'accesses_list_personactivity', 'rule_personactivityactive', 'accesses_rules_personactivityactive', 'othercontact_list_personactivity', 'access_details_personactivity', 'ca_list_personactivity', 'board_list_personactivity', 'presence_attendance_eventuser', 'adherent_contact_personactivity', 'network_list_activities', 'invitations_list_guest', 'organization_cotisation_steps_activities'])]
  67. private $name;
  68. /**
  69. *
  70. * @var ActivityType
  71. */
  72. #[ORM\ManyToOne(targetEntity: '\AppBundle\Entity\Organization\ActivityType')]
  73. #[Groups(['activity', 'access_detail_personactivity', 'network_list_activities', 'activity_reference', 'organization_cotisation_steps_activities'])]
  74. private $activityType;
  75. /**
  76. * @var Organization
  77. *
  78. * @DefaultField
  79. */
  80. #[ORM\ManyToOne(targetEntity: 'Organization', inversedBy: 'activities')]
  81. #[ORM\JoinColumn(nullable: false)]
  82. #[Assert\NotNull]
  83. #[Groups(['activity'])]
  84. private $organization;
  85. /**
  86. * @var ArrayCollection<Categories>
  87. */
  88. #[Assert\Valid]
  89. #[ORM\ManyToMany(targetEntity: '\AppBundle\Entity\Core\Categories', cascade: ['persist'])]
  90. #[Groups(['activity_categories'])]
  91. private $categories;
  92. /**
  93. * @var ArrayCollection<PersonActivity>
  94. */
  95. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Person\PersonActivity', mappedBy: 'activity')]
  96. #[Groups(['organization_access'])]
  97. private $personActivities;
  98. /**
  99. * @var ArrayCollection<Tagg>
  100. */
  101. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'activities')]
  102. #[Assert\Valid]
  103. #[ORM\JoinTable(name: 'tag_activity', joinColumns: [], inverseJoinColumns: [])]
  104. #[ORM\JoinColumn(name: 'activity_id', referencedColumnName: 'id')]
  105. #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  106. #[Groups(['activity_tags', 'manage_tags'])]
  107. private $tags;
  108. /**
  109. * @var string
  110. * @ExportSplitFields({"name","activityType.subFamillyType"})
  111. */
  112. #[Groups(['network_list_activities'])]
  113. private $fullLabelTemplate;
  114. public function __construct() {
  115. $this->categories = new ArrayCollection();
  116. $this->personActivities = new ArrayCollection();
  117. $this->tags = new ArrayCollection();
  118. }
  119. /**
  120. * Sets id.
  121. *
  122. * @param int $id
  123. *
  124. * @return $this
  125. */
  126. public function setId($id)
  127. {
  128. $this->id = $id;
  129. return $this;
  130. }
  131. /**
  132. * Gets id.
  133. *
  134. * @return int
  135. */
  136. public function getId()
  137. {
  138. return $this->id;
  139. }
  140. /**
  141. * Sets description.
  142. *
  143. * @param string $description
  144. *
  145. * @return $this
  146. */
  147. public function setDescription($description)
  148. {
  149. $this->description = $description;
  150. return $this;
  151. }
  152. /**
  153. * Gets description.
  154. *
  155. * @return string
  156. */
  157. public function getDescription()
  158. {
  159. return $this->description;
  160. }
  161. /**
  162. * Sets name.
  163. *
  164. * @param string $name
  165. *
  166. * @return $this
  167. */
  168. public function setName($name)
  169. {
  170. $this->name = $name;
  171. return $this;
  172. }
  173. /**
  174. * Gets name.
  175. *
  176. * @return string
  177. */
  178. public function getName()
  179. {
  180. return $this->name;
  181. }
  182. /**
  183. * Sets organization.
  184. *
  185. * @param Organization $organization
  186. *
  187. * @return $this
  188. */
  189. public function setOrganization(Organization $organization)
  190. {
  191. $this->organization = $organization;
  192. return $this;
  193. }
  194. /**
  195. * Gets organization.
  196. *
  197. * @return Organization
  198. */
  199. public function getOrganization()
  200. {
  201. return $this->organization;
  202. }
  203. /**
  204. * Add category
  205. *
  206. * @param \AppBundle\Entity\Core\Categories $category
  207. *
  208. * @return Activity
  209. */
  210. public function addCategory(\AppBundle\Entity\Core\Categories $category)
  211. {
  212. $this->categories[] = $category;
  213. return $this;
  214. }
  215. /**
  216. * Remove category
  217. *
  218. * @param \AppBundle\Entity\Core\Categories $category
  219. */
  220. public function removeCategory(\AppBundle\Entity\Core\Categories $category)
  221. {
  222. $this->categories->removeElement($category);
  223. }
  224. /**
  225. * Get categories
  226. *
  227. * @return \Doctrine\Common\Collections\Collection
  228. */
  229. public function getCategories()
  230. {
  231. return $this->categories;
  232. }
  233. /**
  234. * Set logo
  235. *
  236. * @param \AppBundle\Entity\Core\File $logo
  237. *
  238. * @return Activity
  239. */
  240. public function setLogo(\AppBundle\Entity\Core\File $logo = null)
  241. {
  242. $this->logo = $logo;
  243. return $this;
  244. }
  245. /**
  246. * Get logo
  247. *
  248. * @return \AppBundle\Entity\Core\File
  249. */
  250. public function getLogo()
  251. {
  252. return $this->logo;
  253. }
  254. /**
  255. * Set imageActivity
  256. *
  257. * @param \AppBundle\Entity\Core\File $imageActivity
  258. *
  259. * @return Activity
  260. */
  261. public function setImageActivity(\AppBundle\Entity\Core\File $imageActivity = null)
  262. {
  263. $this->imageActivity = $imageActivity;
  264. return $this;
  265. }
  266. /**
  267. * Get imageActivity
  268. *
  269. * @return \AppBundle\Entity\Core\File
  270. */
  271. public function getImageActivity()
  272. {
  273. return $this->imageActivity;
  274. }
  275. /**
  276. * Set activityType
  277. *
  278. * @param \AppBundle\Entity\Organization\ActivityType $activityType
  279. *
  280. * @return Activity
  281. */
  282. public function setActivityType(\AppBundle\Entity\Organization\ActivityType $activityType = null)
  283. {
  284. $this->activityType = $activityType;
  285. return $this;
  286. }
  287. /**
  288. * Get activityType
  289. *
  290. * @return \AppBundle\Entity\Organization\ActivityType
  291. */
  292. public function getActivityType()
  293. {
  294. return $this->activityType;
  295. }
  296. /**
  297. * Add personActivity
  298. *
  299. * @param \AppBundle\Entity\Person\PersonActivity $personActivity
  300. *
  301. * @return Activity
  302. */
  303. public function addPersonActivity(\AppBundle\Entity\Person\PersonActivity $personActivity)
  304. {
  305. $this->personActivities[] = $personActivity;
  306. return $this;
  307. }
  308. /**
  309. * Remove personActivity
  310. *
  311. * @param \AppBundle\Entity\Person\PersonActivity $personActivity
  312. */
  313. public function removePersonActivity(\AppBundle\Entity\Person\PersonActivity $personActivity)
  314. {
  315. $this->personActivities->removeElement($personActivity);
  316. }
  317. /**
  318. * Get personActivities
  319. *
  320. * @return \Doctrine\Common\Collections\Collection
  321. */
  322. public function getPersonActivities()
  323. {
  324. return $this->personActivities;
  325. }
  326. /**
  327. * @return array
  328. */
  329. public function getFullLabelTemplate()
  330. {
  331. return array($this->getName(), array("value" => $this->getActivityType() ? $this->getActivityType()->getSubFamillyType() : null, "translate" => true));
  332. }
  333. /**
  334. * Add tag
  335. *
  336. * @param \AppBundle\Entity\Core\Tagg $tag
  337. *
  338. * @return Activity
  339. */
  340. public function addTag(\AppBundle\Entity\Core\Tagg $tag)
  341. {
  342. $this->tags[] = $tag;
  343. return $this;
  344. }
  345. /**
  346. * Remove tag
  347. *
  348. * @param \AppBundle\Entity\Core\Tagg $tag
  349. */
  350. public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
  351. {
  352. $this->tags->removeElement($tag);
  353. }
  354. /**
  355. * Get tags
  356. *
  357. * @return \Doctrine\Common\Collections\Collection
  358. */
  359. public function getTags()
  360. {
  361. return $this->tags;
  362. }
  363. }