function ConstraintViolationBuilder::addViolation
Same name in this branch
- 11.1.x vendor/symfony/validator/Violation/ConstraintViolationBuilder.php \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::addViolation()
Overrides ConstraintViolationBuilderInterface::addViolation
File
-
core/
lib/ Drupal/ Core/ Validation/ ConstraintViolationBuilder.php, line 146
Class
- ConstraintViolationBuilder
- A constraint violation builder for the basic Symfony validator.
Namespace
Drupal\Core\ValidationCode
public function addViolation() : void {
if (NULL === $this->plural) {
$translatedMessage = $this->translator
->trans($this->message, $this->parameters, $this->translationDomain);
}
else {
try {
$translatedMessage = $this->translator
->transChoice($this->message, $this->plural, $this->parameters, $this->translationDomain);
} catch (\InvalidArgumentException $e) {
$translatedMessage = $this->translator
->trans($this->message, $this->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));
}