public function ConstraintViolationBuilder::addViolation in Plug 7
Adds the violation to the current execution context.
Overrides ConstraintViolationBuilderInterface::addViolation
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Violation/ ConstraintViolationBuilder.php, line 187
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));
}