public function ExecutionContext::buildViolation

public ExecutionContext::buildViolation($message, array $parameters = array())

Returns a builder for adding a violation with extended information.

Call {@link ConstraintViolationBuilderInterface::addViolation()} to add the violation when you're done with the configuration:

$context->buildViolation('Please enter a number between %min% and %max%.') ->setParameter('%min%', 3) ->setParameter('%max%', 10) ->setTranslationDomain('number_validation') ->addViolation();

Parameters

string $message The error message:

array $parameters The parameters substituted in the error message:

Return value

ConstraintViolationBuilderInterface The violation builder

Overrides ExecutionContextInterface::buildViolation

File

core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php, line 172

Class

ExecutionContext
Defines an execution context class.

Namespace

Drupal\Core\TypedData\Validation

Code

public function buildViolation($message, array $parameters = array()) {
  return new ConstraintViolationBuilder($this->violations, $this->constraint, $message, $parameters, $this->root, $this->propertyPath, $this->value, $this->translator, $this->translationDomain);
}

© 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!ExecutionContext.php/function/ExecutionContext::buildViolation/8.1.x