PersonActivity.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <?php
  2. namespace AppBundle\Entity\Person;
  3. use AppBundle\Entity\Traits\ActivityPeriodTrait;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Dunglas\ApiBundle\Annotation\Iri;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use AppBundle\Entity\Organization\Activity as Activity;
  9. use AppBundle\Entity\Product\EquipmentList as EquipmentList;
  10. use AppBundle\Entity\Traits\TimestampableEntity;
  11. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  12. /**
  13. * Lien entre une Person et une Activity
  14. *
  15. * @Iri("http://schema.org/PersonActivity")
  16. */
  17. #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Person\Repository\PersonActivityRepository')]
  18. class PersonActivity
  19. {
  20. use TimestampableEntity;
  21. use CreatorUpdaterEntity;
  22. use ActivityPeriodTrait;
  23. /**
  24. * @var int
  25. */
  26. #[ORM\Column(type: 'integer')]
  27. #[ORM\Id]
  28. #[ORM\GeneratedValue(strategy: 'AUTO')]
  29. #[Groups(['personactivity', 'access_details', 'student_list', 'adherent_list', 'accesses_list', 'rule', 'accesses_rules', 'othercontact_list', 'ca_list', 'board_list', 'licence_cmf', 'adherent_contact'])]
  30. private $id;
  31. /**
  32. * @var Access
  33. */
  34. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'personActivity')]
  35. #[ORM\JoinColumn(nullable: false)]
  36. #[Assert\NotNull]
  37. #[Groups(['personactivity'])]
  38. private $access;
  39. /**
  40. * @var Activity
  41. */
  42. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Activity', inversedBy: 'personActivities')]
  43. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  44. #[Groups(['personactivity', 'access_detail_personactivity', 'student_list_personactivity', 'adherent_list_personactivity', 'accesses_list_personactivity', 'rule_personactivityactive', 'accesses_rules_personactivityactive', 'othercontact_list_personactivity', 'ca_list_personactivity', 'access_details_personactivity', 'board_list_personactivity', 'presence_attendance_eventuser', 'adherent_contact_personactivity', 'invitations_list_guest'])]
  45. private $activity;
  46. /**
  47. * @var EquipmentList
  48. */
  49. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Product\EquipmentList')]
  50. #[Groups(['personactivity', 'access_detail_personactivity', 'rule_personactivityactive', 'student_list_personactivity', 'adherent_list_personactivity', 'accesses_list_personactivity', 'rule_personactivityactive', 'accesses_rules_personactivityactive', 'othercontact_list_personactivity', 'ca_list_personactivity', 'presence_attendance_eventuser', 'access_details_personactivity', 'board_list_personactivity', 'adherent_contact_personactivity', 'invitations_list_guest'])]
  51. private $speciality;
  52. /**
  53. * @var string
  54. */
  55. #[ORM\Column(type: 'string', nullable: true)]
  56. #[Assert\Type(type: 'string')]
  57. #[Groups(['personactivity', 'access_detail_personactivity', 'access_details_personactivity'])]
  58. private $complementSpeciality;
  59. /**
  60. * @var bool
  61. */
  62. #[ORM\Column(type: 'boolean', options: ['default' => false])]
  63. #[Assert\Type(type: 'boolean')]
  64. #[Assert\NotNull]
  65. #[Groups(['personactivity', 'access_detail_personactivity', 'adherent_list_personactivity'])]
  66. private $mainActivity = false;
  67. /**
  68. * @var string
  69. */
  70. #[Groups(['template', 'access_detail_personactivity', 'invitations_list_guest'])]
  71. private $fullLabelTemplate;
  72. /**
  73. * Sets id.
  74. *
  75. * @param int $id
  76. *
  77. * @return $this
  78. */
  79. public function setId($id)
  80. {
  81. $this->id = $id;
  82. return $this;
  83. }
  84. /**
  85. * Gets id.
  86. *
  87. * @return int
  88. */
  89. public function getId()
  90. {
  91. return $this->id;
  92. }
  93. /**
  94. * Sets activity.
  95. *
  96. * @param Activity $activity
  97. *
  98. * @return $this
  99. */
  100. public function setActivity(Activity $activity = null)
  101. {
  102. $this->activity = $activity;
  103. return $this;
  104. }
  105. /**
  106. * Gets activity.
  107. *
  108. * @return Activity
  109. */
  110. public function getActivity()
  111. {
  112. return $this->activity;
  113. }
  114. /**
  115. * Sets speciality.
  116. *
  117. * @param EquipmentList $speciality
  118. *
  119. * @return $this
  120. */
  121. public function setSpeciality(EquipmentList $speciality = null)
  122. {
  123. $this->speciality = $speciality;
  124. return $this;
  125. }
  126. /**
  127. * Gets speciality.
  128. *
  129. * @return EquipmentList
  130. */
  131. public function getSpeciality()
  132. {
  133. return $this->speciality;
  134. }
  135. /**
  136. * Sets complementSpeciality.
  137. *
  138. * @param string $complementSpeciality
  139. *
  140. * @return $this
  141. */
  142. public function setcomplementSpeciality($complementSpeciality)
  143. {
  144. $this->complementSpeciality = $complementSpeciality;
  145. return $this;
  146. }
  147. /**
  148. * Gets complementSpeciality.
  149. *
  150. * @return string
  151. */
  152. public function getcomplementSpeciality()
  153. {
  154. return $this->complementSpeciality;
  155. }
  156. /**
  157. * Sets mainActivity.
  158. *
  159. * @param bool $mainActivity
  160. *
  161. * @return $this
  162. */
  163. public function setMainActivity($mainActivity)
  164. {
  165. $this->mainActivity = $mainActivity;
  166. return $this;
  167. }
  168. /**
  169. * Gets mainActivity.
  170. *
  171. * @return bool
  172. */
  173. public function getMainActivity()
  174. {
  175. return $this->mainActivity;
  176. }
  177. /**
  178. * Set access
  179. *
  180. * @param \AppBundle\Entity\AccessAndFunction\Access $access
  181. *
  182. * @return PersonActivity
  183. */
  184. public function setAccess(\AppBundle\Entity\AccessAndFunction\Access $access)
  185. {
  186. $this->access = $access;
  187. return $this;
  188. }
  189. /**
  190. * Get access
  191. *
  192. * @return \AppBundle\Entity\AccessAndFunction\Access
  193. */
  194. public function getAccess()
  195. {
  196. return $this->access;
  197. }
  198. /**
  199. * Gets full label.
  200. *
  201. * @return array
  202. */
  203. public function getFullLabelTemplate()
  204. {
  205. return [
  206. ['value' => $this->getActivity() ? $this->getActivity()->getName() : '', 'separator' => ' - '],
  207. ['value' => $this->getSpeciality() ? $this->getSpeciality()->getDetail() : '', 'translate' => true]
  208. ];
  209. }
  210. }