ConfigInstaller
class ConfigInstaller implements ConfigInstallerInterface (View source)
Properties
| protected ConfigFactoryInterface | $configFactory | The configuration factory. |
|
| protected StorageInterface[] | $activeStorages | The active configuration storages, keyed by collection. |
|
| protected TypedConfigManagerInterface | $typedConfig | The typed configuration manager. |
|
| protected ConfigManagerInterface | $configManager | The configuration manager. |
|
| protected EventDispatcherInterface | $eventDispatcher | The event dispatcher. |
|
| protected StorageInterface | $sourceStorage | The configuration storage that provides the default configuration. |
|
| protected bool | $isSyncing | Is configuration being created as part of a configuration sync. |
|
| protected string | $installProfile | The name of the currently active installation profile. |
Methods
Constructs the configuration installer.
Installs the default configuration of a given extension.
Installs optional configuration.
Gets configuration data from the provided storage to create.
Creates configuration in a collection based on the provided list.
Installs all default configuration in the specified collection.
Sets the configuration storage that provides the default configuration.
Gets the configuration storage that provides the default configuration.
Gets the configuration storage that provides the active configuration.
Sets the status of the isSyncing flag.
Gets the syncing state.
Finds pre-existing configuration objects for the provided extension.
Checks the configuration that will be installed for an extension.
Finds default configuration with unmet dependencies.
Validates an array of config data that contains dependency information.
Returns an array of missing dependencies for a config object.
Gets the list of enabled extensions including both modules and themes.
Gets the profile storage to use to check for profile overrides.
Gets an extension's default configuration directory.
Wrapper for drupal_get_path().
Gets the install profile from settings.
Details
__construct(ConfigFactoryInterface $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, ConfigManagerInterface $config_manager, EventDispatcherInterface $event_dispatcher, string $install_profile)
Constructs the configuration installer.
installDefaultConfig(string $type, string $name)
Installs the default configuration of a given extension.
When an extension is installed, it searches all the default configuration directories for all other extensions to locate any configuration with its name prefix. For example, the Node module provides the frontpage view as a default configuration file: core/modules/node/config/install/views.view.frontpage.yml When the Views module is installed after the Node module is already enabled, the frontpage view will be installed.
Additionally, the default configuration directory for the extension being installed is searched to discover if it contains default configuration that is owned by other enabled extensions. So, the frontpage view will also be installed when the Node module is installed after Views.
installOptionalConfig(StorageInterface $storage = NULL, array $dependency = [])
Installs optional configuration.
Optional configuration is only installed if:
- the configuration does not exist already.
- it's a configuration entity.
- its dependencies can be met.
protected array
getConfigToCreate(StorageInterface $storage, string $collection, string $prefix = '', array $profile_storages = [])
Gets configuration data from the provided storage to create.
protected
createConfiguration(string $collection, array $config_to_create)
Creates configuration in a collection based on the provided list.
installCollectionDefaultConfig(string $collection)
Installs all default configuration in the specified collection.
The function is useful if the site needs to respond to an event that has just created another collection and we need to check all the installed extensions for any matching configuration. For example, if a language has just been created.
$this
setSourceStorage(StorageInterface $storage)
Sets the configuration storage that provides the default configuration.
StorageInterface|null
getSourceStorage()
Gets the configuration storage that provides the default configuration.
protected StorageInterface
getActiveStorages(string $collection = StorageInterface::DEFAULT_COLLECTION)
Gets the configuration storage that provides the active configuration.
$this
setSyncing(bool $status)
Sets the status of the isSyncing flag.
bool
isSyncing()
Gets the syncing state.
protected array
findPreExistingConfiguration(StorageInterface $storage)
Finds pre-existing configuration objects for the provided extension.
Extensions can not be installed if configuration objects exist in the active storage with the same names. This can happen in a number of ways, commonly:
- if a user has created configuration with the same name as that provided by the extension.
- if the extension provides default configuration that does not depend on it and the extension has been uninstalled and is about to the reinstalled.
checkConfigurationToInstall(string $type, string $name)
Checks the configuration that will be installed for an extension.
protected array
findDefaultConfigWithUnmetDependencies(StorageInterface $storage, array $enabled_extensions, array $profile_storages = [])
Finds default configuration with unmet dependencies.
protected bool
validateDependencies(string $config_name, array $data, array $enabled_extensions, array $all_config)
Validates an array of config data that contains dependency information.
protected array
getMissingDependencies(string $config_name, array $data, array $enabled_extensions, array $all_config)
Returns an array of missing dependencies for a config object.
protected array
getEnabledExtensions()
Gets the list of enabled extensions including both modules and themes.
protected StorageInterface[]|null
getProfileStorages(string $installing_name = '')
Gets the profile storage to use to check for profile overrides.
The install profile can override module configuration during a module install. Both the install and optional directories are checked for matching configuration. This allows profiles to override default configuration for modules they do not depend on.
protected string
getDefaultConfigDirectory(string $type, string $name)
Gets an extension's default configuration directory.
protected string
drupalGetPath($type, $name)
Wrapper for drupal_get_path().
protected string|null
drupalGetProfile()
Gets the install profile from settings.
protected bool
drupalInstallationAttempted()
deprecated
deprecated
Wrapper for drupal_installation_attempted().