You are here

class ScheduledDateProvidedConstraintValidator in Sitewide Alert 8

Validates the UniqueInteger constraint.

Hierarchy

Expanded class hierarchy of ScheduledDateProvidedConstraintValidator

File

src/Plugin/Validation/Constraint/ScheduledDateProvidedConstraintValidator.php, line 11

Namespace

Drupal\sitewide_alert\Plugin\Validation\Constraint
View source
class ScheduledDateProvidedConstraintValidator extends ConstraintValidator {

  /**
   * Validator 2.5 and upwards compatible execution context.
   *
   * @var \Symfony\Component\Validator\Context\ExecutionContextInterface
   */
  protected $context;

  /**
   * {@inheritdoc}
   */
  public function validate($entity, Constraint $constraint) {
    if ($entity
      ->isScheduled() && ($entity
      ->getScheduledStartDateTime() === NULL || $entity
      ->getScheduledEndDateTime() === NULL)) {
      $this->context
        ->buildViolation($constraint->messageDatesNotProvided)
        ->atPath('scheduled_date')
        ->addViolation();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ScheduledDateProvidedConstraintValidator::$context protected property Validator 2.5 and upwards compatible execution context.
ScheduledDateProvidedConstraintValidator::validate public function Checks if the passed value is valid.