<?php
namespace App\Entity;
use App\Entity\AutomatedEmailNotificationDefinition\AutomatedEmailNotificationDefinition;
use App\Utility\GuidUtility;
use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException;
/**
* @ORM\Entity
*
* @ORM\Table(name="notifications")
*/
class Notification
{
public const TARGET_GROUP_JOBSEEKERS = 0;
public const TARGET_GROUP_JOBOFFERERS = 1;
public const EMAIL_NOTIFICATION_TRIGGER_POINT_ACCOUNT_CONFIRMATION = 0;
public const TRIGGER_POINTS = [
self::EMAIL_NOTIFICATION_TRIGGER_POINT_ACCOUNT_CONFIRMATION
];
public function __construct(int $notificationType)
{
$this->isActive = true;
$this->targetGroups = [];
$this->triggerPoint = null;
$this->notificationType = $notificationType;
$this->containsCancelLink = false;
$this->notificationInterval = [];
}
/**
* @ORM\GeneratedValue(strategy="CUSTOM")
*
* @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
*
* @ORM\Column(name="id", type="guid")
*
* @ORM\Id
*/
protected string $id;
public function getId(): string
{
return $this->id;
}
public function setId(string $id): void
{
GuidUtility::validOrThrow($id);
$this->id = $id;
}
/**
* @ORM\Column(type="integer", nullable=false)
*/
private int $notificationType;
public function getNotificationType(): int
{
return $this->notificationType;
}
public function setNotificationType(int $notificationType): void
{
$this->notificationType = $notificationType;
}
/**
* @ORM\OneToOne(targetEntity="App\Entity\AutomatedEmailNotificationDefinition\AutomatedEmailNotificationDefinition", mappedBy="notification", cascade={"persist", "remove"})
*/
private AutomatedEmailNotificationDefinition $automatedEmailNotificationDefinition;
public function getAutomatedEmailNotificationDefinition(): AutomatedEmailNotificationDefinition
{
return $this->automatedEmailNotificationDefinition;
}
public function setAutomatedEmailNotificationDefinition(AutomatedEmailNotificationDefinition $automatedEmailNotificationDefinition): void
{
$this->automatedEmailNotificationDefinition = $automatedEmailNotificationDefinition;
}
/**
* @var int[]
*
* @ORM\Column(type="array", nullable=false)
*/
private array $notificationInterval;
/** @return int[] */
public function getNotificationInterval(): array
{
return $this->notificationInterval;
}
/** @param int[] */
public function setNotificationInterval(array $notificationInterval): void
{
$this->notificationInterval = $notificationInterval;
}
/**
* @ORM\Column(type="boolean", nullable=false)
*/
private bool $containsCancelLink;
public function containsCancelLink(): bool
{
return $this->containsCancelLink;
}
public function setContainsCancelLink(bool $containsCancelLink): void
{
$this->containsCancelLink = $containsCancelLink;
}
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $amountOfNotificationsSentForCancelLinkToAppear;
public function getAmountOfNotificationsSentForCancelLinkToAppear(): ?int
{
return $this->amountOfNotificationsSentForCancelLinkToAppear;
}
public function setAmountOfNotificationsSentForCancelLinkToAppear(?int $amountOfNotificationsSentForCancelLinkToAppear): void
{
$this->amountOfNotificationsSentForCancelLinkToAppear = $amountOfNotificationsSentForCancelLinkToAppear;
}
/**
* @ORM\Column(type="boolean", nullable=false, options={"default": true})
*/
private bool $isActive;
public function isActive(): bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): void
{
$this->isActive = $isActive;
}
/**
* @ORM\Column(type="integer", nullable=false, options={"default": 0})
*/
private int $maxNumberOfSendsPerUser;
public function getMaxNumberOfSendsPerUser(): int
{
return $this->maxNumberOfSendsPerUser;
}
public function setMaxNumberOfSendsPerUser(int $maxNumberOfSendsPerUser): void
{
$this->maxNumberOfSendsPerUser = $maxNumberOfSendsPerUser;
}
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $triggerPoint;
public function getTriggerPoint(): ?int
{
return $this->triggerPoint;
}
public function setTriggerPoint(?int $triggerPoint): void
{
if (!is_null($triggerPoint) && !in_array($triggerPoint, self::TRIGGER_POINTS)) {
throw new InvalidArgumentException("Tried to set unknown trigger point '$triggerPoint'.");
}
$this->triggerPoint = $triggerPoint;
}
/**
* @var int[]
*
* @ORM\Column(type="array", nullable=false)
*/
private array $targetGroups;
public function getTargetGroups(): array
{
return $this->targetGroups;
}
public function setTargetGroups(array $targetGroups): void
{
$this->targetGroups = $targetGroups;
}
}