Rename the Plan bundle to Program across config, routes, menus, and controllers (Plan -> Initiative), bump version to 0.16.0, and introduce new audience and UTM taxonomy routes and permissions to support the expanded Programs feature set.
33 lines
920 B
PHP
33 lines
920 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MauticPlugin\ProgramBundle\Validator\Constraints;
|
|
|
|
use MauticPlugin\ProgramBundle\Entity\Task;
|
|
use MauticPlugin\ProgramBundle\Entity\TaskKind;
|
|
use Symfony\Component\Validator\Constraint;
|
|
use Symfony\Component\Validator\ConstraintValidator;
|
|
|
|
/**
|
|
* Enforces the task kind's date rules. A milestone's end date is enslaved to its start date: the
|
|
* validator copies the start date onto the end date before validation, so the saved task always
|
|
* carries start = end.
|
|
*/
|
|
class TaskDatesValidator extends ConstraintValidator
|
|
{
|
|
/**
|
|
* @param Task $task
|
|
*/
|
|
public function validate($task, Constraint $constraint): void
|
|
{
|
|
if (!$task instanceof Task) {
|
|
return;
|
|
}
|
|
|
|
if (TaskKind::Milestone === $task->getTaskKind() && null !== $task->getStartDate()) {
|
|
$task->setEndDate(clone $task->getStartDate());
|
|
}
|
|
}
|
|
}
|