public function SchedulerPublishOnConstraintValidator::validate in Scheduler 2.x
Same name and namespace in other branches
- 8 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 = \Drupal::service('scheduler.manager')
->getThirdPartySetting($entity
->getEntity(), '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();
}
}