src/App/Entity/Notification.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\AutomatedEmailNotificationDefinition\AutomatedEmailNotificationDefinition;
  4. use App\Utility\GuidUtility;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use InvalidArgumentException;
  7. /**
  8. * @ORM\Entity
  9. *
  10. * @ORM\Table(name="notifications")
  11. */
  12. class Notification
  13. {
  14. public const TARGET_GROUP_JOBSEEKERS = 0;
  15. public const TARGET_GROUP_JOBOFFERERS = 1;
  16. public const EMAIL_NOTIFICATION_TRIGGER_POINT_ACCOUNT_CONFIRMATION = 0;
  17. public const TRIGGER_POINTS = [
  18. self::EMAIL_NOTIFICATION_TRIGGER_POINT_ACCOUNT_CONFIRMATION
  19. ];
  20. public function __construct(int $notificationType)
  21. {
  22. $this->isActive = true;
  23. $this->targetGroups = [];
  24. $this->triggerPoint = null;
  25. $this->notificationType = $notificationType;
  26. $this->containsCancelLink = false;
  27. $this->notificationInterval = [];
  28. }
  29. /**
  30. * @ORM\GeneratedValue(strategy="CUSTOM")
  31. *
  32. * @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
  33. *
  34. * @ORM\Column(name="id", type="guid")
  35. *
  36. * @ORM\Id
  37. */
  38. protected string $id;
  39. public function getId(): string
  40. {
  41. return $this->id;
  42. }
  43. public function setId(string $id): void
  44. {
  45. GuidUtility::validOrThrow($id);
  46. $this->id = $id;
  47. }
  48. /**
  49. * @ORM\Column(type="integer", nullable=false)
  50. */
  51. private int $notificationType;
  52. public function getNotificationType(): int
  53. {
  54. return $this->notificationType;
  55. }
  56. public function setNotificationType(int $notificationType): void
  57. {
  58. $this->notificationType = $notificationType;
  59. }
  60. /**
  61. * @ORM\OneToOne(targetEntity="App\Entity\AutomatedEmailNotificationDefinition\AutomatedEmailNotificationDefinition", mappedBy="notification", cascade={"persist", "remove"})
  62. */
  63. private AutomatedEmailNotificationDefinition $automatedEmailNotificationDefinition;
  64. public function getAutomatedEmailNotificationDefinition(): AutomatedEmailNotificationDefinition
  65. {
  66. return $this->automatedEmailNotificationDefinition;
  67. }
  68. public function setAutomatedEmailNotificationDefinition(AutomatedEmailNotificationDefinition $automatedEmailNotificationDefinition): void
  69. {
  70. $this->automatedEmailNotificationDefinition = $automatedEmailNotificationDefinition;
  71. }
  72. /**
  73. * @var int[]
  74. *
  75. * @ORM\Column(type="array", nullable=false)
  76. */
  77. private array $notificationInterval;
  78. /** @return int[] */
  79. public function getNotificationInterval(): array
  80. {
  81. return $this->notificationInterval;
  82. }
  83. /** @param int[] */
  84. public function setNotificationInterval(array $notificationInterval): void
  85. {
  86. $this->notificationInterval = $notificationInterval;
  87. }
  88. /**
  89. * @ORM\Column(type="boolean", nullable=false)
  90. */
  91. private bool $containsCancelLink;
  92. public function containsCancelLink(): bool
  93. {
  94. return $this->containsCancelLink;
  95. }
  96. public function setContainsCancelLink(bool $containsCancelLink): void
  97. {
  98. $this->containsCancelLink = $containsCancelLink;
  99. }
  100. /**
  101. * @ORM\Column(type="integer", nullable=true)
  102. */
  103. private ?int $amountOfNotificationsSentForCancelLinkToAppear;
  104. public function getAmountOfNotificationsSentForCancelLinkToAppear(): ?int
  105. {
  106. return $this->amountOfNotificationsSentForCancelLinkToAppear;
  107. }
  108. public function setAmountOfNotificationsSentForCancelLinkToAppear(?int $amountOfNotificationsSentForCancelLinkToAppear): void
  109. {
  110. $this->amountOfNotificationsSentForCancelLinkToAppear = $amountOfNotificationsSentForCancelLinkToAppear;
  111. }
  112. /**
  113. * @ORM\Column(type="boolean", nullable=false, options={"default": true})
  114. */
  115. private bool $isActive;
  116. public function isActive(): bool
  117. {
  118. return $this->isActive;
  119. }
  120. public function setIsActive(bool $isActive): void
  121. {
  122. $this->isActive = $isActive;
  123. }
  124. /**
  125. * @ORM\Column(type="integer", nullable=false, options={"default": 0})
  126. */
  127. private int $maxNumberOfSendsPerUser;
  128. public function getMaxNumberOfSendsPerUser(): int
  129. {
  130. return $this->maxNumberOfSendsPerUser;
  131. }
  132. public function setMaxNumberOfSendsPerUser(int $maxNumberOfSendsPerUser): void
  133. {
  134. $this->maxNumberOfSendsPerUser = $maxNumberOfSendsPerUser;
  135. }
  136. /**
  137. * @ORM\Column(type="integer", nullable=true)
  138. */
  139. private ?int $triggerPoint;
  140. public function getTriggerPoint(): ?int
  141. {
  142. return $this->triggerPoint;
  143. }
  144. public function setTriggerPoint(?int $triggerPoint): void
  145. {
  146. if (!is_null($triggerPoint) && !in_array($triggerPoint, self::TRIGGER_POINTS)) {
  147. throw new InvalidArgumentException("Tried to set unknown trigger point '$triggerPoint'.");
  148. }
  149. $this->triggerPoint = $triggerPoint;
  150. }
  151. /**
  152. * @var int[]
  153. *
  154. * @ORM\Column(type="array", nullable=false)
  155. */
  156. private array $targetGroups;
  157. public function getTargetGroups(): array
  158. {
  159. return $this->targetGroups;
  160. }
  161. public function setTargetGroups(array $targetGroups): void
  162. {
  163. $this->targetGroups = $targetGroups;
  164. }
  165. }