src/Entity/Notification.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\NotificationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. /**
  9. * @ORM\Entity(repositoryClass=NotificationRepository::class)
  10. * @Serializer\ExclusionPolicy("ALL")
  11. */
  12. class Notification extends BaseEntity
  13. {
  14. /**
  15. * @ORM\Id
  16. * @ORM\GeneratedValue
  17. * @ORM\Column(type="integer")
  18. * @Serializer\Expose
  19. */
  20. private $id;
  21. /**
  22. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="notifications")
  23. * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  24. */
  25. private $receiver;
  26. /**
  27. * @ORM\Column(type="string", length=255)
  28. * @Serializer\Expose
  29. */
  30. private $title;
  31. /**
  32. * @ORM\Column(type="string", length=255)
  33. * @Serializer\Expose
  34. */
  35. private $message;
  36. /**
  37. * @ORM\Column(type="string", length=255, nullable=true)
  38. */
  39. private $objectType;
  40. /**
  41. * @ORM\Column(type="integer", nullable=true)
  42. */
  43. private $objectId;
  44. /**
  45. * @ORM\Column(type="boolean", nullable=true)
  46. * @Serializer\Expose
  47. */
  48. private $isRead = false;
  49. /**
  50. * @ORM\Column(type="array", nullable=true)
  51. */
  52. private $topics = [];
  53. /**
  54. * @ORM\OneToMany(targetEntity=NotificationReceiver::class, mappedBy="notification", cascade={"remove"}, fetch="EXTRA_LAZY"))
  55. */
  56. private $notificationReceivers;
  57. /**
  58. * @ORM\ManyToOne(targetEntity=Comment::class, inversedBy="notifications")
  59. */
  60. private $comment;
  61. /**
  62. * @ORM\Column(type="string", length=255, nullable=true)
  63. * @Serializer\Expose
  64. */
  65. private $action;
  66. /**
  67. * @ORM\ManyToOne(targetEntity=Module::class, inversedBy="notifications")
  68. * @Serializer\Expose
  69. */
  70. private $module;
  71. /**
  72. * @ORM\ManyToOne(targetEntity=Subject::class, inversedBy="notifications")
  73. */
  74. private $subject;
  75. public function __construct()
  76. {
  77. $this->notificationReceivers = new ArrayCollection();
  78. }
  79. public function getId(): ?int
  80. {
  81. return $this->id;
  82. }
  83. public function getReceiver(): ?User
  84. {
  85. return $this->receiver;
  86. }
  87. public function setReceiver(?User $receiver): self
  88. {
  89. $this->receiver = $receiver;
  90. return $this;
  91. }
  92. public function getTitle(): ?string
  93. {
  94. return $this->title;
  95. }
  96. public function setTitle(string $title): self
  97. {
  98. $this->title = $title;
  99. return $this;
  100. }
  101. public function getMessage(): ?string
  102. {
  103. return $this->message;
  104. }
  105. public function setMessage(string $message): self
  106. {
  107. $this->message = $message;
  108. return $this;
  109. }
  110. public function getObjectType(): ?string
  111. {
  112. return $this->objectType;
  113. }
  114. public function setObjectType(?string $objectType): self
  115. {
  116. $this->objectType = $objectType;
  117. return $this;
  118. }
  119. public function getObjectId(): ?int
  120. {
  121. return $this->objectId;
  122. }
  123. public function setObjectId(?int $objectId): self
  124. {
  125. $this->objectId = $objectId;
  126. return $this;
  127. }
  128. public function isIsRead(): ?bool
  129. {
  130. return $this->isRead;
  131. }
  132. public function setIsRead(?bool $isRead): self
  133. {
  134. $this->isRead = $isRead;
  135. return $this;
  136. }
  137. public function getTopics(): ?array
  138. {
  139. return $this->topics;
  140. }
  141. public function setTopics(?array $topics): self
  142. {
  143. $this->topics = $topics;
  144. return $this;
  145. }
  146. /**
  147. * @return Collection<int, NotificationReceiver>
  148. */
  149. public function getNotificationReceivers(): Collection
  150. {
  151. return $this->notificationReceivers;
  152. }
  153. public function addNotificationReceiver(NotificationReceiver $notificationReceiver): self
  154. {
  155. if (!$this->notificationReceivers->contains($notificationReceiver)) {
  156. $this->notificationReceivers[] = $notificationReceiver;
  157. $notificationReceiver->setNotification($this);
  158. }
  159. return $this;
  160. }
  161. public function removeNotificationReceiver(NotificationReceiver $notificationReceiver): self
  162. {
  163. if ($this->notificationReceivers->removeElement($notificationReceiver)) {
  164. // set the owning side to null (unless already changed)
  165. if ($notificationReceiver->getNotification() === $this) {
  166. $notificationReceiver->setNotification(null);
  167. }
  168. }
  169. return $this;
  170. }
  171. public function getComment(): ?Comment
  172. {
  173. return $this->comment;
  174. }
  175. public function setComment(?Comment $comment): self
  176. {
  177. $this->comment = $comment;
  178. return $this;
  179. }
  180. public function getAction(): ?string
  181. {
  182. return $this->action;
  183. }
  184. public function setAction(?string $action): self
  185. {
  186. $this->action = $action;
  187. return $this;
  188. }
  189. public function getModule(): ?Module
  190. {
  191. return $this->module;
  192. }
  193. public function setModule(?Module $module): self
  194. {
  195. $this->module = $module;
  196. return $this;
  197. }
  198. public function getSubject(): ?Subject
  199. {
  200. return $this->subject;
  201. }
  202. public function setSubject(?Subject $subject): self
  203. {
  204. $this->subject = $subject;
  205. return $this;
  206. }
  207. }