class ConfigSchemaChecker implements EventSubscriberInterface (View source)

Listens to the config save event and validates schema.

If tests have the $strictConfigSchema property set to TRUE this event listener will be added to the container and throw exceptions if configuration is invalid.

Traits

Provides a trait for checking configuration schema.

Properties

protected Element $schema

The config schema wrapper object for the configuration object under test.

from  SchemaCheckTrait
protected string $configName

The configuration object name under test.

from  SchemaCheckTrait
protected TypedConfigManagerInterface $typedManager

The typed config manger.

protected array $checked

An array of config checked already. Keyed by config name and a checksum.

protected string[] $exclude

An array of config object names that are excluded from schema checking.

Methods

array|bool
checkConfigSchema(TypedConfigManagerInterface $typed_config, string $config_name, array $config_data)

Checks the TypedConfigManager has a valid schema for the configuration.

array
checkValue(string $key, mixed $value)

Helper method to check data type.

__construct(TypedConfigManagerInterface $typed_manager, array $exclude = [])

Constructs the ConfigSchemaChecker object.

onConfigSave(ConfigCrudEvent $event)

Checks that configuration complies with its schema on config save.

static 
getSubscribedEvents()

{@inheritdoc}

Details

array|bool checkConfigSchema(TypedConfigManagerInterface $typed_config, string $config_name, array $config_data)

Checks the TypedConfigManager has a valid schema for the configuration.

Parameters

TypedConfigManagerInterface $typed_config

The TypedConfigManager.

string $config_name

The configuration name.

array $config_data

The configuration data, assumed to be data for a top-level config object.

Return Value

array|bool

FALSE if no schema found. List of errors if any found. TRUE if fully valid.

protected array checkValue(string $key, mixed $value)

Helper method to check data type.

Parameters

string $key

A string of configuration key.

mixed $value

Value of given key.

Return Value

array

List of errors found while checking with the corresponding schema.

__construct(TypedConfigManagerInterface $typed_manager, array $exclude = [])

Constructs the ConfigSchemaChecker object.

Parameters

TypedConfigManagerInterface $typed_manager

The typed config manager.

array $exclude

An array of config object names that are excluded from schema checking.

onConfigSave(ConfigCrudEvent $event)

Checks that configuration complies with its schema on config save.

Parameters

ConfigCrudEvent $event

The configuration event.

Exceptions

SchemaIncompleteException

static getSubscribedEvents()

{@inheritdoc}