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.
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MauticPlugin\ProgramBundle\Validator\Constraints;
|
|
|
|
use MauticPlugin\ProgramBundle\Entity\DateRangeInterface;
|
|
use Symfony\Component\Validator\Constraint;
|
|
use Symfony\Component\Validator\ConstraintValidator;
|
|
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
|
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
|
|
|
class EndDateAfterStartDateValidator extends ConstraintValidator
|
|
{
|
|
public function validate(mixed $value, Constraint $constraint): void
|
|
{
|
|
if (!$constraint instanceof EndDateAfterStartDate) {
|
|
throw new UnexpectedTypeException($constraint, EndDateAfterStartDate::class);
|
|
}
|
|
|
|
if (null === $value) {
|
|
return;
|
|
}
|
|
|
|
if (!$value instanceof DateRangeInterface) {
|
|
throw new UnexpectedValueException($value, DateRangeInterface::class);
|
|
}
|
|
|
|
$start = $value->getStartDate();
|
|
$end = $value->getEndDate();
|
|
|
|
if (null === $start || null === $end || $end >= $start) {
|
|
return;
|
|
}
|
|
|
|
$this->context->buildViolation($constraint->message)
|
|
->atPath('endDate')
|
|
->addViolation();
|
|
}
|
|
}
|