public function SchedulerPublishOnConstraintValidator::validate in Scheduler 8
Same name and namespace in other branches
- 2.x src/Plugin/Validation/Constraint/SchedulerPublishOnConstraintValidator.php \Drupal\scheduler\Plugin\Validation\Constraint\SchedulerPublishOnConstraintValidator::validate()
File
- src/
Plugin/ Validation/ Constraint/ SchedulerPublishOnConstraintValidator.php, line 16
Class
- SchedulerPublishOnConstraintValidator
- Validates the SchedulerPublishOn constraint.
Namespace
Drupal\scheduler\Plugin\Validation\ConstraintCode
public function validate($entity, Constraint $constraint) {
$publish_on = $entity->value;
$default_publish_past_date = \Drupal::config('scheduler.settings')
->get('default_publish_past_date');
$scheduler_publish_past_date = $entity
->getEntity()->type->entity
->getThirdPartySetting('scheduler', 'publish_past_date', $default_publish_past_date);
if ($publish_on && $scheduler_publish_past_date == 'error' && $publish_on < \Drupal::time()
->getRequestTime()) {
$this->context
->buildViolation($constraint->messagePublishOnDateNotInFuture)
->atPath('publish_on')
->addViolation();
}
}