Configuration Provider
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
This module is not useful on its own, and should only be installed if it's required by another module.
Configuration Provider provides a plugin type for extension-provided configuration. It includes support for the two core extension types, config/install and config/optional. Contributed modules may provide their own plugins that serve distinct use cases.
Background and use case
Drupal core's configuration management system supports two directory types for extension-provided configuration, InstallStorage::CONFIG_INSTALL_DIRECTORY and InstallStorage::CONFIG_OPTIONAL_DIRECTORY, with most relevant code in the ConfigInstaller class.
The structure of the code is suitable for the use case of staging configuration, but has several shortcomings when it comes to other use cases.
- It's not easy for contributed modules to provide additional configuration providers that meet distinct use cases. Examples of such are the Configuration Share module, which provides a config/share directory, and the planned Configuration Merge module.
- It's not easy to answer the question: what configuration would be provided if the currently installed modules were reinstalled? For example, the logic to determine what optional configuration will be installed is embedded in
ConfigInstaller::installOptionalConfig(), which doesn't just determine what will be installed but installs the configuration. This question is a critical one for solutions like Configuration Synchronizer, which aims to merge configuration updates from updated extensions into the active configuration.
Configuration Provider addresses these use cases by providing a plugin type that modules can use to extend core's built in configuration provision directories. To do so, it overrides the ConfigInstaller class to provide a custom ::getConfigToInstall() method that passes the request to all available configuration provider plugins. In doing so, it also passes configuration data provided by previous provider plugins, allowing a plugin to accomplish tasks like (a) fulfill configuration entity dependency requirements on demand (as in Configuration Share) or (b) modify configuration prior to it being installed (as in Configuration Merge).
API
The config_provider.collector service provides a method ::getInstallableConfig(), that can be used to determine what configuration would be installed if all currently installed extensions (modules, themes, and the install profile) were reinstalled. Sample usage:
$collector = Drupal::service('config_provider.collector');
$config = $collector->getInstallableConfig();
This method may be used for example as part of an update workflow, to determine what updates are available from installed extensions.
The plugin.manager.config_provider.processor service provides a method, ::getDefinitions(), that can be used to load definitions of all available ConfigProvider plugins. Sample usage:
$config_provider_manager = Drupal::service('plugin.manager.config_provider.processor');
$definitions = $config_provider_manager->getDefinitions();
