class InvalidConfigException
Same name in other branches
- 10 core/lib/Drupal/Core/Recipe/InvalidConfigException.php \Drupal\Core\Recipe\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
5 files declare their use of InvalidConfigException
- AddItemToToolbarConfigActionTest.php in core/
modules/ ckeditor5/ tests/ src/ Kernel/ ConfigAction/ AddItemToToolbarConfigActionTest.php - ConfigActionManager.php in core/
lib/ Drupal/ Core/ Config/ Action/ ConfigActionManager.php - ConfigActionValidationTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Recipe/ ConfigActionValidationTest.php - ConfigValidationTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Recipe/ ConfigValidationTest.php - WildcardConfigActionsTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Recipe/ WildcardConfigActionsTest.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. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.