public ConstraintViolationBuilder::addViolation()
Adds the violation to the current execution context.
Overrides ConstraintViolationBuilderInterface::addViolation
File
- core/lib/Drupal/Core/TypedData/Validation/ConstraintViolationBuilder.php, line 216
Class
- ConstraintViolationBuilder
- Defines a constraint violation builder for the Typed Data validator.
Namespace
Drupal\Core\TypedData\Validation
Code
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 )); }
Please login to continue.