Commission.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <?php
  2. namespace AppBundle\Entity\Person;
  3. use AppBundle\Entity\Core\Tagg;
  4. use AppBundle\Entity\Organization\Organization;
  5. use AppBundle\Entity\Traits\ActivityPeriodTrait;
  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\Validator\Constraints\Delete as OpentalentDelete;
  14. use AppBundle\Annotation\DefaultField;
  15. /**
  16. * Commission à l'intérieur d'une Organization
  17. *
  18. * @Iri("http://schema.org/Commission")
  19. * @OpentalentDelete\EntityDelete()
  20. */
  21. #[ORM\Entity]
  22. class Commission
  23. {
  24. use TimestampableEntity;
  25. use CreatorUpdaterEntity;
  26. use ActivityPeriodTrait;
  27. /**
  28. * @var int
  29. */
  30. #[ORM\Column(type: 'integer')]
  31. #[ORM\Id]
  32. #[ORM\GeneratedValue(strategy: 'AUTO')]
  33. #[Groups(['commission', 'commission_list'])]
  34. private $id;
  35. /**
  36. * @var Organization
  37. *
  38. * @DefaultField
  39. */
  40. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'commissions')]
  41. #[ORM\JoinColumn(nullable: false)]
  42. #[Assert\NotNull]
  43. #[Groups(['commission'])]
  44. private $organization;
  45. /**
  46. * @var string
  47. */
  48. #[ORM\Column(type: 'string', length: 60)]
  49. #[Assert\Type(type: 'string')]
  50. #[Assert\NotNull]
  51. #[Groups(['commission', 'commission_list'])]
  52. private $name;
  53. /**
  54. * @var string
  55. */
  56. #[ORM\Column(type: 'string', length: 50, nullable: true)]
  57. #[Assert\Type(type: 'string')]
  58. #[Groups(['commission', 'commission_list'])]
  59. private $type;
  60. /**
  61. * @var string
  62. */
  63. #[ORM\Column(type: 'string', length: 127, nullable: true)]
  64. #[Assert\Type(type: 'string')]
  65. #[Groups(['commission', 'commission_list'])]
  66. private $description;
  67. /**
  68. * @var ArrayCollection<CommissionMember>
  69. */
  70. #[Groups(['commission_commissionmember', 'commission_list'])]
  71. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Person\CommissionMember', cascade: ['persist'], mappedBy: 'commission', orphanRemoval: true)]
  72. private $commissionMembers;
  73. /**
  74. * @var ArrayCollection<Tagg>
  75. */
  76. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'commissions')]
  77. #[Assert\Valid]
  78. #[ORM\JoinTable(name: 'tag_commission', joinColumns: [], inverseJoinColumns: [])]
  79. #[ORM\JoinColumn(name: 'commission_id', referencedColumnName: 'id')]
  80. #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  81. #[Groups(['commission_tags', 'manage_tags', 'commission_list'])]
  82. private $tags;
  83. /**
  84. * Constructor
  85. */
  86. public function __construct()
  87. {
  88. $this->commissionMembers = new ArrayCollection();
  89. $this->tags = new ArrayCollection();
  90. }
  91. /**
  92. * Sets id.
  93. *
  94. * @param int $id
  95. *
  96. * @return $this
  97. */
  98. public function setId($id)
  99. {
  100. $this->id = $id;
  101. return $this;
  102. }
  103. /**
  104. * Gets id.
  105. *
  106. * @return int
  107. */
  108. public function getId()
  109. {
  110. return $this->id;
  111. }
  112. /**
  113. * Sets name.
  114. *
  115. * @param string $name
  116. *
  117. * @return $this
  118. */
  119. public function setName($name)
  120. {
  121. $this->name = $name;
  122. return $this;
  123. }
  124. /**
  125. * Gets name.
  126. *
  127. * @return string
  128. */
  129. public function getName()
  130. {
  131. return $this->name;
  132. }
  133. /**
  134. * Sets type.
  135. *
  136. * @param string $type
  137. *
  138. * @return $this
  139. */
  140. public function setType($type)
  141. {
  142. $this->type = $type;
  143. return $this;
  144. }
  145. /**
  146. * Gets type.
  147. *
  148. * @return string
  149. */
  150. public function getType()
  151. {
  152. return $this->type;
  153. }
  154. /**
  155. * Sets description.
  156. *
  157. * @param string $description
  158. *
  159. * @return $this
  160. */
  161. public function setDescription($description)
  162. {
  163. $this->description = $description;
  164. return $this;
  165. }
  166. /**
  167. * Gets description.
  168. *
  169. * @return string
  170. */
  171. public function getDescription()
  172. {
  173. return $this->description;
  174. }
  175. /**
  176. * Add commissionMember
  177. *
  178. * @param \AppBundle\Entity\Person\CommissionMember $commissionMember
  179. *
  180. * @return Commission
  181. */
  182. public function addCommissionMember(\AppBundle\Entity\Person\CommissionMember $commissionMember)
  183. {
  184. $this->commissionMembers[] = $commissionMember;
  185. $commissionMember->setCommission($this);
  186. return $this;
  187. }
  188. /**
  189. * Remove commissionMember
  190. *
  191. * @param \AppBundle\Entity\Person\CommissionMember $commissionMember
  192. */
  193. public function removeCommissionMember(\AppBundle\Entity\Person\CommissionMember $commissionMember)
  194. {
  195. $this->commissionMembers->removeElement($commissionMember);
  196. }
  197. /**
  198. * Get commissionMembers
  199. *
  200. * @return \Doctrine\Common\Collections\Collection
  201. */
  202. public function getCommissionMembers()
  203. {
  204. return $this->commissionMembers;
  205. }
  206. /**
  207. * Set organization
  208. *
  209. * @param \AppBundle\Entity\Organization\Organization $organization
  210. *
  211. * @return Commission
  212. */
  213. public function setOrganization(\AppBundle\Entity\Organization\Organization $organization)
  214. {
  215. $this->organization = $organization;
  216. return $this;
  217. }
  218. /**
  219. * Get organization
  220. *
  221. * @return \AppBundle\Entity\Organization\Organization
  222. */
  223. public function getOrganization()
  224. {
  225. return $this->organization;
  226. }
  227. /**
  228. * Add tag
  229. *
  230. * @param \AppBundle\Entity\Core\Tagg $tag
  231. *
  232. * @return Commission
  233. */
  234. public function addTag(\AppBundle\Entity\Core\Tagg $tag)
  235. {
  236. $this->tags[] = $tag;
  237. return $this;
  238. }
  239. /**
  240. * Remove tag
  241. *
  242. * @param \AppBundle\Entity\Core\Tagg $tag
  243. */
  244. public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
  245. {
  246. $this->tags->removeElement($tag);
  247. }
  248. /**
  249. * Get tags
  250. *
  251. * @return \Doctrine\Common\Collections\Collection
  252. */
  253. public function getTags()
  254. {
  255. return $this->tags;
  256. }
  257. }