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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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.