public function ExistsValidator::validate in Markdown 8.2
File
- src/
Plugin/ Validation/ Constraint/ ExistsValidator.php, line 22
Class
- ExistsValidator
- Validates that a class, interface, trait, or function exists.
Namespace
Drupal\markdown\Plugin\Validation\ConstraintCode
public function validate($class, Constraint $constraint) {
if (!is_string($class) || empty($class) || !class_exists($class) && !interface_exists($class) && !trait_exists($class) && !function_exists($class) && !defined($class) && !is_callable($class)) {
// Passing an already translated message allows markup to be preserved
// when it passes to the theme system.
$message = t($constraint->message, [
'@name' => isset($constraint->name) ? Markup::create($constraint->name) : $class,
]);
$this->context
->addViolation($message);
}
}