function InvalidConfigException::formatMessage

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Recipe/InvalidConfigException.php \Drupal\Core\Recipe\InvalidConfigException::formatMessage()

Formats the constraint violation list as a human-readable message.

Return value

string The formatted message.

1 call to InvalidConfigException::formatMessage()
InvalidConfigException::__construct in core/lib/Drupal/Core/Recipe/InvalidConfigException.php
Constructs an InvalidConfigException object.

File

core/lib/Drupal/Core/Recipe/InvalidConfigException.php, line 49

Class

InvalidConfigException
Thrown if config created or changed by a recipe fails validation.

Namespace

Drupal\Core\Recipe

Code

private function formatMessage() : string {
    $lines = [
        sprintf('There were validation errors in %s:', $this->data
            ->getName()),
    ];
    
    /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
    foreach ($this->violations as $violation) {
        $lines[] = sprintf('- %s: %s', $violation->getPropertyPath(), $violation->getMessage());
    }
    return implode("\n", $lines);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.