public function ConstraintViolationBuilder::addViolation
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\ValidationCode
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 )); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!TypedData!Validation!ConstraintViolationBuilder.php/function/ConstraintViolationBuilder::addViolation/8.1.x