class InvalidConfigException
Same name in this branch
- 11.1.x vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.php \JsonSchema\Exception\InvalidConfigException
Thrown if config created or changed by a recipe fails validation.
@internal This API is experimental.
Hierarchy
- class \Drupal\Core\Recipe\InvalidConfigException extends \Drupal\Core\Recipe\RuntimeException
Expanded class hierarchy of InvalidConfigException
1 file declares its use of InvalidConfigException
- ConfigActionManager.php in core/
lib/ Drupal/ Core/ Config/ Action/ ConfigActionManager.php
File
-
core/
lib/ Drupal/ Core/ Recipe/ InvalidConfigException.php, line 16
Namespace
Drupal\Core\RecipeView source
final class InvalidConfigException extends \RuntimeException {
/**
* Constructs an InvalidConfigException object.
*
* @param \Symfony\Component\Validator\ConstraintViolationList $violations
* The validation constraint violations.
* @param \Drupal\Core\Config\Schema\Mapping $data
* A typed data wrapper around the invalid config data.
* @param string $message
* (optional) The exception message. Defaults to the string representation
* of the constraint violation list.
* @param int $code
* (optional) The exception code. Defaults to 0.
* @param \Throwable|null $previous
* (optional) The previous exception, if any.
*/
public function __construct(ConstraintViolationList $violations, Mapping $data, string $message = '', int $code = 0, ?\Throwable $previous = NULL) {
parent::__construct($message ?: $this->formatMessage(), $code, $previous);
}
/**
* Formats the constraint violation list as a human-readable message.
*
* @return string
* The formatted message.
*/
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);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
InvalidConfigException::formatMessage | private | function | Formats the constraint violation list as a human-readable message. |
InvalidConfigException::__construct | public | function | Constructs an InvalidConfigException object. |