this.getStartDate()', message: 'The start date must be before warning date')] #[ORM\Column(name: 'start_date', type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE, nullable: true)] private ?\DateTime $startDate = null; /** * @var Collection */ #[ORM\OneToMany(targetEntity: SingleTaskPlaceEvent::class, mappedBy: 'task', cascade: ['remove'])] private Collection $taskPlaceEvents; #[Serializer\Groups(['read'])] #[Assert\Expression('!(value != null and this.getEndDate() == null)', message: 'An end date is required if a warning interval is set')] #[ORM\Column(name: 'warning_interval', type: \Doctrine\DBAL\Types\Types::DATEINTERVAL, nullable: true)] private ?\DateInterval $warningInterval = null; public function __construct() { $this->taskPlaceEvents = new ArrayCollection(); } /** * Get endDate. */ public function getEndDate(): ?\DateTime { return $this->endDate; } /** * Get id. * * @return int */ public function getId() { return $this->id; } public function getRecurringTask(): RecurringTask { return $this->recurringTask; } /** * Get startDate. * * @return \DateTime */ public function getStartDate() { return $this->startDate; } public function getTaskPlaceEvents(): Collection { return $this->taskPlaceEvents; } /** * Get the Warning date, computed from the difference between the * end date and the warning interval. * * Return null if warningDate or endDate is null * * @return \DateTimeImmutable */ #[Serializer\Groups(['read'])] public function getWarningDate() { if (null === $this->getWarningInterval()) { return null; } if (null === $this->getEndDate()) { return null; } return \DateTimeImmutable::createFromMutable($this->getEndDate()) ->sub($this->getWarningInterval()); } /** * Get warningInterval. */ public function getWarningInterval(): ?\DateInterval { return $this->warningInterval; } /** * Set endDate. * * @param \DateTime $endDate * * @return SingleTask */ public function setEndDate(?\DateTime $endDate) { $this->endDate = $endDate; return $this; } public function setRecurringTask(RecurringTask $recurringTask) { $this->recurringTask = $recurringTask; } /** * Set startDate. * * @param \DateTime $startDate * * @return SingleTask */ public function setStartDate(?\DateTime $startDate) { $this->startDate = $startDate; return $this; } public function setTaskPlaceEvents(Collection $taskPlaceEvents) { $this->taskPlaceEvents = $taskPlaceEvents; return $this; } /** * Set warningInterval. * * @return SingleTask */ public function setWarningInterval(?\DateInterval $warningInterval) { $this->warningInterval = $warningInterval; return $this; } }