public function ExecutionContext::addViolation

public ExecutionContext::addViolation($message, array $parameters = array(), $invalidValue = NULL, $plural = NULL, $code = NULL)

File

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

Class

ExecutionContext
Defines an execution context class.

Namespace

Drupal\Core\TypedData\Validation

Code

public function addViolation($message, array $parameters = array(), $invalidValue = NULL, $plural = NULL, $code = NULL) {
  // The parameters $invalidValue and following are ignored by the new
  // API, as they are not present in the new interface anymore.
  // You should use buildViolation() instead.
  if (func_num_args() > 2) {
    throw new \LogicException('Legacy validator API is unsupported.');
  }

  $this->violations->add(new ConstraintViolation($this->translator->trans($message, $parameters, $this->translationDomain), $message, $parameters, $this->root, $this->propertyPath, $this->value, NULL, NULL, $this->constraint));
}

© 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::addViolation/8.1.x