class DateRecurTimeZoneConstraintValidator in Recurring Dates Field 3.1.x
Same name and namespace in other branches
- 8.2 src/Plugin/Validation/Constraint/DateRecurTimeZoneConstraintValidator.php \Drupal\date_recur\Plugin\Validation\Constraint\DateRecurTimeZoneConstraintValidator
- 3.x src/Plugin/Validation/Constraint/DateRecurTimeZoneConstraintValidator.php \Drupal\date_recur\Plugin\Validation\Constraint\DateRecurTimeZoneConstraintValidator
- 3.0.x src/Plugin/Validation/Constraint/DateRecurTimeZoneConstraintValidator.php \Drupal\date_recur\Plugin\Validation\Constraint\DateRecurTimeZoneConstraintValidator
Validates the DateRecurTimeZone constraint.
Hierarchy
- class \Drupal\date_recur\Plugin\Validation\Constraint\DateRecurTimeZoneConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator
Expanded class hierarchy of DateRecurTimeZoneConstraintValidator
File
- src/
Plugin/ Validation/ Constraint/ DateRecurTimeZoneConstraintValidator.php, line 13
Namespace
Drupal\date_recur\Plugin\Validation\ConstraintView source
class DateRecurTimeZoneConstraintValidator extends ConstraintValidator {
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint) {
assert($constraint instanceof DateRecurTimeZoneConstraint);
$timeZones = \DateTimeZone::listIdentifiers();
if (is_string($value) && !in_array($value, $timeZones)) {
$this->context
->addViolation($constraint->invalidTimeZone, [
'%value' => $value,
]);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DateRecurTimeZoneConstraintValidator:: |
public | function |