public function ValidPathConstraintValidator::validate in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Path/Plugin/Validation/Constraint/ValidPathConstraintValidator.php \Drupal\Core\Path\Plugin\Validation\Constraint\ValidPathConstraintValidator::validate()
File
- core/
lib/ Drupal/ Core/ Path/ Plugin/ Validation/ Constraint/ ValidPathConstraintValidator.php, line 45
Class
- ValidPathConstraintValidator
- Constraint validator for validating system paths.
Namespace
Drupal\Core\Path\Plugin\Validation\ConstraintCode
public function validate($value, Constraint $constraint) {
if (!isset($value)) {
return;
}
$path = trim($value, '/');
if (!$this->pathValidator
->isValid($path)) {
$this->context
->addViolation($constraint->message, [
'%link_path' => $value,
]);
}
}