Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ConstraintViolationBuilder.php

function ConstraintViolationBuilder::addViolation

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/Validation/ConstraintViolationBuilder.php \Drupal\Core\Validation\ConstraintViolationBuilder::addViolation()

Overrides ConstraintViolationBuilderInterface::addViolation

File

vendor/symfony/validator/Violation/ConstraintViolationBuilder.php, line 114

Class

ConstraintViolationBuilder
Default implementation of {@link ConstraintViolationBuilderInterface}.

Namespace

Symfony\Component\Validator\Violation

Code

public function addViolation() : void {
    $parameters = null === $this->plural ? $this->parameters : [
        '%count%' => $this->plural,
    ] + $this->parameters;
    if (false === $this->translationDomain) {
        $translatedMessage = strtr($this->message, $parameters);
    }
    else {
        $translatedMessage = $this->translator
            ->trans($this->message, $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));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal