AbstractInformation.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?php
  2. namespace AppBundle\Entity\Core;
  3. use AppBundle\Entity\Organization\Organization;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Dunglas\ApiBundle\Annotation\Iri;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use AppBundle\Annotation\DefaultField;
  10. use AppBundle\Entity\Traits\TimestampableEntity;
  11. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  12. /**
  13. * Classe de base des notifications et des tips
  14. *
  15. *
  16. */
  17. #[ORM\Entity]
  18. #[ORM\Table(name: 'Information')]
  19. #[ORM\InheritanceType('SINGLE_TABLE')]
  20. #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
  21. #[ORM\DiscriminatorMap(['notification' => 'Notification', 'tips' => 'Tips'])]
  22. abstract class AbstractInformation
  23. {
  24. use TimestampableEntity;
  25. use CreatorUpdaterEntity;
  26. /**
  27. * @var int
  28. */
  29. #[ORM\Column(type: 'integer')]
  30. #[ORM\Id]
  31. #[ORM\GeneratedValue(strategy: 'AUTO')]
  32. #[Groups(['information', 'tips', 'notification'])]
  33. private $id;
  34. /**
  35. * @var string
  36. */
  37. #[ORM\Column(type: 'string', length: 40, nullable: true)]
  38. #[Assert\Type(type: 'string')]
  39. #[Groups(['information', 'tips', 'notification'])]
  40. private $name;
  41. /**
  42. * @var \DateTime
  43. */
  44. #[ORM\Column(type: 'datetime', nullable: true)]
  45. #[Assert\DateTime]
  46. #[Groups(['information', 'tips', 'notification'])]
  47. private $datetimeStart;
  48. /**
  49. * @var \DateTime
  50. */
  51. #[ORM\Column(type: 'datetime', nullable: true)]
  52. #[Assert\DateTime]
  53. #[Groups(['information', 'tips', 'notification'])]
  54. private $datetimeEnd;
  55. /**
  56. * @var bool
  57. */
  58. #[ORM\Column(type: 'boolean', options: ['default' => true])]
  59. #[Assert\Type(type: 'boolean')]
  60. #[Assert\NotNull]
  61. #[Groups(['information', 'tips', 'notification'])]
  62. private $activate = true;
  63. /**
  64. * @var bool
  65. */
  66. #[ORM\Column(type: 'boolean', options: ['default' => 0])]
  67. #[Assert\Type(type: 'boolean')]
  68. #[Assert\NotNull]
  69. #[Groups(['information', 'tips', 'notification'])]
  70. private $isSystem = false;
  71. /**
  72. * @var ArrayCollection<NotificationUser>
  73. */
  74. #[Assert\Valid]
  75. #[ORM\OneToMany(targetEntity: 'NotificationUser', mappedBy: 'notification', cascade: ['persist'], orphanRemoval: true)]
  76. #[Groups(['information', 'tips', 'notification'])]
  77. private $notificationUsers;
  78. /**
  79. * The constructor
  80. */
  81. public function __construct() {
  82. $this->notificationUsers = new ArrayCollection();
  83. }
  84. /**
  85. * Sets id.
  86. *
  87. * @param int $id
  88. *
  89. * @return $this
  90. */
  91. public function setId($id)
  92. {
  93. $this->id = $id;
  94. return $this;
  95. }
  96. /**
  97. * Gets id.
  98. *
  99. * @return int
  100. */
  101. public function getId()
  102. {
  103. return $this->id;
  104. }
  105. /**
  106. * Set activate
  107. *
  108. * @param boolean $activate
  109. *
  110. * @return AbstractInformation
  111. */
  112. public function setActivate($activate)
  113. {
  114. $this->activate = $activate;
  115. return $this;
  116. }
  117. /**
  118. * Get activate
  119. *
  120. * @return boolean
  121. */
  122. public function getActivate()
  123. {
  124. return $this->activate;
  125. }
  126. /**
  127. * Set isSystem
  128. *
  129. * @param boolean $isSystem
  130. *
  131. * @return AbstractInformation
  132. */
  133. public function setIsSystem($isSystem)
  134. {
  135. $this->isSystem = $isSystem;
  136. return $this;
  137. }
  138. /**
  139. * Get isSystem
  140. *
  141. * @return boolean
  142. */
  143. public function getIsSystem()
  144. {
  145. return $this->isSystem;
  146. }
  147. /**
  148. * Set name
  149. *
  150. * @param string $name
  151. *
  152. * @return AbstractInformation
  153. */
  154. public function setName($name)
  155. {
  156. $this->name = $name;
  157. return $this;
  158. }
  159. /**
  160. * Get name
  161. *
  162. * @return string
  163. */
  164. public function getName()
  165. {
  166. return $this->name;
  167. }
  168. /**
  169. * Set datetimeStart
  170. *
  171. * @param \DateTime $datetimeStart
  172. *
  173. * @return AbstractInformation
  174. */
  175. public function setDatetimeStart($datetimeStart)
  176. {
  177. $this->datetimeStart = $datetimeStart;
  178. return $this;
  179. }
  180. /**
  181. * Get datetimeStart
  182. *
  183. * @return \DateTime
  184. */
  185. public function getDatetimeStart()
  186. {
  187. return $this->datetimeStart;
  188. }
  189. /**
  190. * Set datetimeEnd
  191. *
  192. * @param \DateTime $datetimeEnd
  193. *
  194. * @return AbstractInformation
  195. */
  196. public function setDatetimeEnd($datetimeEnd)
  197. {
  198. $this->datetimeEnd = $datetimeEnd;
  199. return $this;
  200. }
  201. /**
  202. * Get datetimeEnd
  203. *
  204. * @return \DateTime
  205. */
  206. public function getDatetimeEnd()
  207. {
  208. return $this->datetimeEnd;
  209. }
  210. /**
  211. * Adds notificationUser.
  212. *
  213. * @param NotificationUser $notificationUser
  214. * @return $this
  215. */
  216. public function addNotificationUser(NotificationUser $notificationUser) {
  217. $notificationUser->setNotification($this);
  218. $this->notificationUsers->add($notificationUser);
  219. return $this;
  220. }
  221. /**
  222. * Remove $notificationUse.
  223. *
  224. * @param NotificationUser $notificationUser
  225. * @return $this
  226. */
  227. public function removeNotificationUser(NotificationUser $notificationUser) {
  228. $notificationUser->setNotification(null);
  229. $this->notificationUsers->remove($notificationUser);
  230. return $this;
  231. }
  232. /**
  233. * Gets notificationUsers
  234. *
  235. * @return ArrayCollection<NotificationUser>
  236. */
  237. public function getNotificationUsers() {
  238. return $this->notificationUsers;
  239. }
  240. }