this.getStartDate()", * message="The start date must be before warning date" * ) */ private ?\DateTime $startDate = null; /** * @var Collection * * @ORM\OneToMany( * targetEntity="\Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent", * mappedBy="task", * cascade={ "remove" } * ) */ private Collection $taskPlaceEvents; /** * @ORM\Column(name="warning_interval", type="dateinterval", nullable=true) * * @Serializer\Groups({"read"}) * * @Assert\Expression( * "!(value != null and this.getEndDate() == null)", * message="An end date is required if a warning interval is set" * ) */ private null|\DateInterval $warningInterval = null; public function __construct() { $this->taskPlaceEvents = new ArrayCollection(); } /** * Get endDate. */ public function getEndDate(): null|\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(): null|\DateInterval { return $this->warningInterval; } /** * Set endDate. * * @param \DateTime $endDate * * @return SingleTask */ public function setEndDate($endDate) { $this->endDate = $endDate; return $this; } public function setRecurringTask(RecurringTask $recurringTask) { $this->recurringTask = $recurringTask; } /** * Set startDate. * * @param \DateTime $startDate * * @return SingleTask */ public function setStartDate($startDate) { $this->startDate = $startDate; return $this; } public function setTaskPlaceEvents(Collection $taskPlaceEvents) { $this->taskPlaceEvents = $taskPlaceEvents; return $this; } /** * Set warningInterval. * * @return SingleTask */ public function setWarningInterval(null|\DateInterval $warningInterval) { $this->warningInterval = $warningInterval; return $this; } }