function ConstraintViolationBuilder::addViolation
Same name in this branch
- 11.1.x core/lib/Drupal/Core/Validation/ConstraintViolationBuilder.php \Drupal\Core\Validation\ConstraintViolationBuilder::addViolation()
Overrides ConstraintViolationBuilderInterface::addViolation
File
-
vendor/
symfony/ validator/ Violation/ ConstraintViolationBuilder.php, line 114
Class
- ConstraintViolationBuilder
- Default implementation of {@link ConstraintViolationBuilderInterface}.
Namespace
Symfony\Component\Validator\ViolationCode
public function addViolation() : void {
$parameters = null === $this->plural ? $this->parameters : [
'%count%' => $this->plural,
] + $this->parameters;
if (false === $this->translationDomain) {
$translatedMessage = strtr($this->message, $parameters);
}
else {
$translatedMessage = $this->translator
->trans($this->message, $parameters, $this->translationDomain);
}
$this->violations
->add(new ConstraintViolation($translatedMessage, $this->message, $this->parameters, $this->root, $this->propertyPath, $this->invalidValue, $this->plural, $this->code, $this->constraint, $this->cause));
}