Drupal 8  8.0.2
ConfigInstaller Class Reference
Inheritance diagram for ConfigInstaller:

Public Member Functions

 __construct (ConfigFactoryInterface $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, ConfigManagerInterface $config_manager, EventDispatcherInterface $event_dispatcher)
 
 installDefaultConfig ($type, $name)
 
 installOptionalConfig (StorageInterface $storage=NULL, $dependency=[])
 
 installCollectionDefaultConfig ($collection)
 
 setSourceStorage (StorageInterface $storage)
 
 getSourceStorage ()
 
 setSyncing ($status)
 
 isSyncing ()
 
 checkConfigurationToInstall ($type, $name)
 

Protected Member Functions

 getConfigToCreate (StorageInterface $storage, $collection, $prefix= '', array $profile_storages=[])
 
 getActiveStorages ($collection=StorageInterface::DEFAULT_COLLECTION)
 
 findPreExistingConfiguration (StorageInterface $storage)
 
 findDefaultConfigWithUnmetDependencies (StorageInterface $storage, array $enabled_extensions, array $profile_storages=[])
 
 validateDependencies ($config_name, array $data, array $enabled_extensions, array $all_config)
 
 getEnabledExtensions ()
 
 getProfileStorages ($installing_name= '')
 
 getDefaultConfigDirectory ($type, $name)
 
 drupalGetPath ($type, $name)
 
 drupalGetProfile ()
 
 drupalInstallationAttempted ()
 

Protected Attributes

 $configFactory
 
 $activeStorages
 
 $typedConfig
 
 $configManager
 
 $eventDispatcher
 
 $sourceStorage
 
 $isSyncing = FALSE
 

Constructor & Destructor Documentation

__construct ( ConfigFactoryInterface  $config_factory,
StorageInterface  $active_storage,
TypedConfigManagerInterface  $typed_config,
ConfigManagerInterface  $config_manager,
EventDispatcherInterface  $event_dispatcher 
)

Constructs the configuration installer.

Parameters
\Drupal\Core\Config\ConfigFactoryInterface$config_factoryThe configuration factory.
\Drupal\Core\Config\StorageInterface$active_storageThe active configuration storage.
\Drupal\Core\Config\TypedConfigManagerInterface$typed_configThe typed configuration manager.
\Drupal\Core\Config\ConfigManagerInterface$config_managerThe configuration manager.
\Symfony\Component\EventDispatcher\EventDispatcherInterface$event_dispatcherThe event dispatcher.

References Drupal\configFactory(), and StorageInterface\getCollectionName().

Here is the call graph for this function:

Member Function Documentation

checkConfigurationToInstall (   $type,
  $name 
)

{Checks the configuration that will be installed for an extension.

Parameters
string$typeType of extension to install.
string$nameName of extension to install.
Exceptions
\Drupal\Core\Config\UnmetDependenciesException
\Drupal\Core\Config\PreExistingConfigException
}

Implements ConfigInstallerInterface.

References PreExistingConfigException\create(), UnmetDependenciesException\create(), StorageInterface\DEFAULT_COLLECTION, ConfigInstaller\drupalGetProfile(), ConfigInstaller\findDefaultConfigWithUnmetDependencies(), ConfigInstaller\findPreExistingConfiguration(), ConfigInstaller\getDefaultConfigDirectory(), ConfigInstaller\getEnabledExtensions(), ConfigInstaller\getProfileStorages(), and ConfigInstaller\isSyncing().

Here is the call graph for this function:

drupalGetPath (   $type,
  $name 
)
protected

Wrapper for drupal_get_path().

Parameters
$typeThe type of the item; one of 'core', 'profile', 'module', 'theme', or 'theme_engine'.
$nameThe name of the item for which the path is requested. Ignored for $type 'core'.
Returns
string The path to the requested item or an empty string if the item is not found.

Referenced by ConfigInstaller\getDefaultConfigDirectory(), ConfigInstaller\getProfileStorages(), ConfigInstaller\installDefaultConfig(), and ConfigInstaller\installOptionalConfig().

Here is the caller graph for this function:

drupalGetProfile ( )
protected

Gets the install profile from settings.

Returns
string|null $profile The name of the installation profile or NULL if no installation profile is currently active. This is the case for example during the first steps of the installer or during unit tests.

References Settings\get().

Referenced by ConfigInstaller\checkConfigurationToInstall(), ConfigInstaller\getProfileStorages(), ConfigInstaller\installDefaultConfig(), and ConfigInstaller\installOptionalConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

drupalInstallationAttempted ( )
protected

Wrapper for drupal_installation_attempted().

Returns
bool TRUE if a Drupal installation is currently being attempted.

Referenced by ConfigInstaller\installCollectionDefaultConfig(), and ConfigInstaller\installDefaultConfig().

Here is the caller graph for this function:

findDefaultConfigWithUnmetDependencies ( StorageInterface  $storage,
array  $enabled_extensions,
array  $profile_storages = [] 
)
protected

Finds default configuration with unmet dependencies.

Parameters
\Drupal\Core\Config\StorageInterface$storageThe storage containing the default configuration.
array$enabled_extensionsA list of all the currently enabled modules and themes.
\Drupal\Core\Config\StorageInterface[]$profile_storages An array of storage interfaces containing profile configuration to check for overrides.
Returns
array List of configuration that has unmet dependencies

References Drupal\configFactory(), StorageInterface\DEFAULT_COLLECTION, ConfigInstaller\getConfigToCreate(), and ConfigInstaller\validateDependencies().

Referenced by ConfigInstaller\checkConfigurationToInstall().

Here is the call graph for this function:

Here is the caller graph for this function:

findPreExistingConfiguration ( StorageInterface  $storage)
protected

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.
Returns
array Array of configuration object names that already exist keyed by collection.

References ConfigInstaller\getActiveStorages(), and ConfigInstaller\getConfigToCreate().

Referenced by ConfigInstaller\checkConfigurationToInstall().

Here is the call graph for this function:

Here is the caller graph for this function:

getActiveStorages (   $collection = StorageInterface::DEFAULT_COLLECTION)
protected

Gets the configuration storage that provides the active configuration.

Parameters
string$collection(optional) The configuration collection. Defaults to the default collection.
Returns
The configuration storage that provides the default configuration.

Referenced by ConfigInstaller\findPreExistingConfiguration(), ConfigInstaller\installCollectionDefaultConfig(), ConfigInstaller\installDefaultConfig(), and ConfigInstaller\installOptionalConfig().

Here is the caller graph for this function:

getConfigToCreate ( StorageInterface  $storage,
  $collection,
  $prefix = '',
array  $profile_storages = [] 
)
protected

Gets configuration data from the provided storage to create.

Parameters
StorageInterface$storageThe configuration storage to read configuration from.
string$collectionThe configuration collection to use.
string$prefix(optional) Limit to configuration starting with the provided string.
\Drupal\Core\Config\StorageInterface[]$profile_storages An array of storage interfaces containing profile configuration to check for overrides.
Returns
array An array of configuration data read from the source storage keyed by the configuration object name.

References StorageInterface\createCollection(), StorageInterface\getCollectionName(), StorageInterface\listAll(), and StorageInterface\readMultiple().

Referenced by ConfigInstaller\findDefaultConfigWithUnmetDependencies(), ConfigInstaller\findPreExistingConfiguration(), and ConfigInstaller\installDefaultConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

getDefaultConfigDirectory (   $type,
  $name 
)
protected

Gets an extension's default configuration directory.

Parameters
string$typeType of extension to install.
string$nameName of extension to install.
Returns
string The extension's default configuration directory.

References InstallStorage\CONFIG_INSTALL_DIRECTORY, and ConfigInstaller\drupalGetPath().

Referenced by ConfigInstaller\checkConfigurationToInstall(), and ConfigInstaller\installDefaultConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

getEnabledExtensions ( )
protected

Gets the list of enabled extensions including both modules and themes.

Returns
array A list of enabled extensions which includes both modules and themes.

References Drupal\configFactory().

Referenced by ConfigInstaller\checkConfigurationToInstall(), ConfigInstaller\installCollectionDefaultConfig(), and ConfigInstaller\installOptionalConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

getProfileStorages (   $installing_name = '')
protected

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.

Parameters
string$installing_name(optional) The name of the extension currently being installed.
Returns
[]|null Storages to access configuration from the installation profile. If we're installing the profile itself, then it will return an empty array as the profile storage should not be used.

References InstallStorage\CONFIG_INSTALL_DIRECTORY, InstallStorage\CONFIG_OPTIONAL_DIRECTORY, StorageInterface\DEFAULT_COLLECTION, ConfigInstaller\drupalGetPath(), and ConfigInstaller\drupalGetProfile().

Referenced by ConfigInstaller\checkConfigurationToInstall(), and ConfigInstaller\installDefaultConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

getSourceStorage ( )

Gets the configuration storage that provides the default configuration.

Returns
|null The configuration storage that provides the default configuration. Returns null if the source storage has not been set.

Referenced by ConfigInstaller\installDefaultConfig().

Here is the caller graph for this function:

installCollectionDefaultConfig (   $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.

Parameters
string$collectionThe configuration collection.
}

Implements ConfigInstallerInterface.

References InstallStorage\CONFIG_INSTALL_DIRECTORY, Drupal\configFactory(), StorageInterface\DEFAULT_COLLECTION, ConfigInstaller\drupalInstallationAttempted(), ConfigInstaller\getActiveStorages(), ConfigInstaller\getEnabledExtensions(), and Unicode\substr().

Here is the call graph for this function:

installDefaultConfig (   $type,
  $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.

Parameters
string$typeThe extension type; e.g., 'module' or 'theme'.
string$nameThe name of the module or theme to install default configuration for.
See Also
}

Implements ConfigInstallerInterface.

References InstallStorage\CONFIG_OPTIONAL_DIRECTORY, InstallStorage\CONFIG_SCHEMA_DIRECTORY, Drupal\configFactory(), StorageInterface\DEFAULT_COLLECTION, ConfigInstaller\drupalGetPath(), ConfigInstaller\drupalGetProfile(), ConfigInstaller\drupalInstallationAttempted(), ConfigInstaller\getActiveStorages(), ConfigInstaller\getConfigToCreate(), ConfigInstaller\getDefaultConfigDirectory(), ConfigInstaller\getProfileStorages(), ConfigInstaller\getSourceStorage(), ConfigInstaller\installOptionalConfig(), and ConfigInstaller\isSyncing().

Here is the call graph for this function:

installOptionalConfig ( StorageInterface  $storage = NULL,
  $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.
Parameters
\Drupal\Core\Config\StorageInterface(optional) The configuration storage to search for optional configuration. If not provided, all enabled extension's optional configuration directories will be searched.
array$dependency(optional) If set, ensures that the configuration being installed has this dependency. The format is dependency type as the key ('module', 'theme', or 'config') and the dependency name as the value ('book', 'bartik', 'views.view.frontpage').
}

Implements ConfigInstallerInterface.

References InstallStorage\CONFIG_OPTIONAL_DIRECTORY, StorageInterface\DEFAULT_COLLECTION, ConfigInstaller\drupalGetPath(), ConfigInstaller\drupalGetProfile(), ConfigInstaller\getActiveStorages(), ConfigInstaller\getEnabledExtensions(), and ConfigInstaller\validateDependencies().

Referenced by ConfigInstaller\installDefaultConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

isSyncing ( )

{Gets the syncing state.

Returns
bool Returns TRUE is syncing flag set.
}

Implements ConfigInstallerInterface.

Referenced by ConfigInstaller\checkConfigurationToInstall(), ConfigInstaller\installDefaultConfig(), and ConfigInstaller\setSyncing().

Here is the caller graph for this function:

setSourceStorage ( StorageInterface  $storage)

{Sets the configuration storage that provides the default configuration.

Parameters
\Drupal\Core\Config\StorageInterface$storage
Returns
$this
}

Implements ConfigInstallerInterface.

setSyncing (   $status)

{Sets the status of the isSyncing flag.

Parameters
bool$statusThe status of the sync flag.
Returns
$this
}

Implements ConfigInstallerInterface.

References ConfigInstaller\isSyncing().

Here is the call graph for this function:

validateDependencies (   $config_name,
array  $data,
array  $enabled_extensions,
array  $all_config 
)
protected

Validates an array of config data that contains dependency information.

Parameters
string$config_nameThe name of the configuration object that is being validated.
array$dataConfiguration data.
array$enabled_extensionsA list of all the currently enabled modules and themes.
array$all_configA list of all the active configuration names.
Returns
bool TRUE if the dependencies are met, FALSE if not.

Referenced by ConfigInstaller\findDefaultConfigWithUnmetDependencies(), and ConfigInstaller\installOptionalConfig().

Here is the caller graph for this function:


The documentation for this class was generated from the following file: