public function ConstraintViolationBuilder::addViolation in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/validator/Violation/ConstraintViolationBuilder.php \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::addViolation()
- 8 core/lib/Drupal/Core/TypedData/Validation/ConstraintViolationBuilder.php \Drupal\Core\TypedData\Validation\ConstraintViolationBuilder::addViolation()
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Violation/ConstraintViolationBuilder.php \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::addViolation()
Adds the violation to the current execution context.
Overrides ConstraintViolationBuilderInterface::addViolation
File
- vendor/
symfony/ validator/ Violation/ ConstraintViolationBuilder.php, line 188
Class
- ConstraintViolationBuilder
- Default implementation of {@link ConstraintViolationBuilderInterface}.
Namespace
Symfony\Component\Validator\ViolationCode
public function addViolation() {
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));
}