You are here

public function ExecutionContext::buildViolation in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/validator/Context/ExecutionContext.php \Symfony\Component\Validator\Context\ExecutionContext::buildViolation()
  2. 8 core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php \Drupal\Core\TypedData\Validation\ExecutionContext::buildViolation()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Context/ExecutionContext.php \Symfony\Component\Validator\Context\ExecutionContext::buildViolation()

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

vendor/symfony/validator/Context/ExecutionContext.php, line 221

Class

ExecutionContext
The context used and created by {@link ExecutionContextFactory}.

Namespace

Symfony\Component\Validator\Context

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);
}