class ExtensionInstallStorage in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Config/ExtensionInstallStorage.php \Drupal\Core\Config\ExtensionInstallStorage
Storage to access configuration and schema in enabled extensions.
Hierarchy
- class \Drupal\Core\Config\FileStorage implements StorageInterface
- class \Drupal\Core\Config\InstallStorage
- class \Drupal\Core\Config\ExtensionInstallStorage
- class \Drupal\Core\Config\InstallStorage
Expanded class hierarchy of ExtensionInstallStorage
See also
\Drupal\Core\Config\ConfigInstaller
\Drupal\Core\Config\TypedConfigManager
2 files declare their use of ExtensionInstallStorage
- ExtensionInstallStorageTest.php in core/
tests/ Drupal/ Tests/ Core/ Config/ ExtensionInstallStorageTest.php - LocaleDefaultConfigStorage.php in core/
modules/ locale/ src/ LocaleDefaultConfigStorage.php
1 string reference to 'ExtensionInstallStorage'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses ExtensionInstallStorage
File
- core/
lib/ Drupal/ Core/ Config/ ExtensionInstallStorage.php, line 13
Namespace
Drupal\Core\ConfigView source
class ExtensionInstallStorage extends InstallStorage {
/**
* The active configuration store.
*
* @var \Drupal\Core\Config\StorageInterface
*/
protected $configStorage;
/**
* Flag to include the profile in the list of enabled modules.
*
* @var bool
*/
protected $includeProfile = TRUE;
/**
* The name of the currently active installation profile.
*
* In the early installer this value can be NULL.
*
* @var string|NULL
*/
protected $installProfile;
/**
* Overrides \Drupal\Core\Config\InstallStorage::__construct().
*
* @param \Drupal\Core\Config\StorageInterface $config_storage
* The active configuration store where the list of enabled modules and
* themes is stored.
* @param string $directory
* The directory to scan in each extension to scan for files.
* @param string $collection
* The collection to store configuration in.
* @param bool $include_profile
* Whether to include the install profile in extensions to
* search and to get overrides from.
* @param string $profile
* The current installation profile.
*/
public function __construct(StorageInterface $config_storage, $directory, $collection, $include_profile, $profile) {
parent::__construct($directory, $collection);
$this->configStorage = $config_storage;
$this->includeProfile = $include_profile;
$this->installProfile = $profile;
}
/**
* {@inheritdoc}
*/
public function createCollection($collection) {
return new static($this->configStorage, $this->directory, $collection, $this->includeProfile, $this->installProfile);
}
/**
* Returns a map of all config object names and their folders.
*
* The list is based on enabled modules and themes. The active configuration
* storage is used rather than \Drupal\Core\Extension\ModuleHandler and
* \Drupal\Core\Extension\ThemeHandler in order to resolve circular
* dependencies between these services and \Drupal\Core\Config\ConfigInstaller
* and \Drupal\Core\Config\TypedConfigManager.
*
* @return array
* An array mapping config object names with directories.
*/
protected function getAllFolders() {
if (!isset($this->folders)) {
$this->folders = [];
$this->folders += $this
->getCoreNames();
$extensions = $this->configStorage
->read('core.extension');
// @todo Remove this scan as part of https://www.drupal.org/node/2186491
$listing = new ExtensionDiscovery(\Drupal::root());
if (!empty($extensions['module'])) {
$modules = $extensions['module'];
// Remove the install profile as this is handled later.
unset($modules[$this->installProfile]);
$profile_list = $listing
->scan('profile');
if ($this->installProfile && isset($profile_list[$this->installProfile])) {
// Prime the \Drupal\Core\Extension\ExtensionList::getPathname()
// static cache with the profile info file location so we can use
// ExtensionList::getPath() on the active profile during the module
// scan.
// @todo Remove as part of https://www.drupal.org/node/2186491
/** @var \Drupal\Core\Extension\ProfileExtensionList $profile_extension_list */
$profile_extension_list = \Drupal::service('extension.list.profile');
$profile_extension_list
->setPathname($this->installProfile, $profile_list[$this->installProfile]
->getPathname());
}
$module_list_scan = $listing
->scan('module');
$module_list = [];
foreach (array_keys($modules) as $module) {
if (isset($module_list_scan[$module])) {
$module_list[$module] = $module_list_scan[$module];
}
}
$this->folders += $this
->getComponentNames($module_list);
}
if (!empty($extensions['theme'])) {
$theme_list_scan = $listing
->scan('theme');
foreach (array_keys($extensions['theme']) as $theme) {
if (isset($theme_list_scan[$theme])) {
$theme_list[$theme] = $theme_list_scan[$theme];
}
}
$this->folders += $this
->getComponentNames($theme_list);
}
if ($this->includeProfile) {
// The install profile can override module default configuration. We do
// this by replacing the config file path from the module/theme with the
// install profile version if there are any duplicates.
if ($this->installProfile) {
if (!isset($profile_list)) {
$profile_list = $listing
->scan('profile');
}
if (isset($profile_list[$this->installProfile])) {
$profile_folders = $this
->getComponentNames([
$profile_list[$this->installProfile],
]);
$this->folders = $profile_folders + $this->folders;
}
}
}
}
return $this->folders;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExtensionInstallStorage:: |
protected | property | The active configuration store. | |
ExtensionInstallStorage:: |
protected | property | Flag to include the profile in the list of enabled modules. | |
ExtensionInstallStorage:: |
protected | property | The name of the currently active installation profile. | |
ExtensionInstallStorage:: |
public | function |
Creates a collection on the storage. Overrides FileStorage:: |
|
ExtensionInstallStorage:: |
protected | function |
Returns a map of all config object names and their folders. Overrides InstallStorage:: |
|
ExtensionInstallStorage:: |
public | function |
Overrides \Drupal\Core\Config\InstallStorage::__construct(). Overrides InstallStorage:: |
|
FileStorage:: |
protected | property | The storage collection. | |
FileStorage:: |
protected | property | The file cache object. | |
FileStorage:: |
public | function |
Decodes configuration data from the storage-specific format. Overrides StorageInterface:: |
|
FileStorage:: |
public | function |
Encodes configuration data into the storage-specific format. Overrides StorageInterface:: |
|
FileStorage:: |
protected | function | Check if the directory exists and create it if not. | |
FileStorage:: |
public | function |
Gets the existing collections. Overrides StorageInterface:: |
|
FileStorage:: |
protected | function | Helper function for getAllCollectionNames(). | |
FileStorage:: |
protected | function | Gets the directory for the collection. | |
FileStorage:: |
public | function |
Gets the name of the current collection the storage is using. Overrides StorageInterface:: |
|
FileStorage:: |
public static | function | Returns the file extension used by the file storage for all configuration files. | |
FileStorage:: |
private | function | Returns file system service. | |
FileStorage:: |
public | function |
Implements Drupal\Core\Config\StorageInterface::read(). Overrides StorageInterface:: |
|
FileStorage:: |
public | function |
Reads configuration data from the storage. Overrides StorageInterface:: |
|
InstallStorage:: |
protected | property |
The directory to scan in each extension to scan for files. Overrides FileStorage:: |
|
InstallStorage:: |
protected | property | Folder map indexed by configuration name. | |
InstallStorage:: |
constant | Extension sub-directory containing default configuration for installation. | ||
InstallStorage:: |
constant | Extension sub-directory containing optional configuration for installation. | ||
InstallStorage:: |
constant | Extension sub-directory containing configuration schema. | ||
InstallStorage:: |
public | function |
Overrides Drupal\Core\Config\FileStorage::delete(). Overrides FileStorage:: |
|
InstallStorage:: |
public | function |
Overrides Drupal\Core\Config\FileStorage::deleteAll(). Overrides FileStorage:: |
|
InstallStorage:: |
public | function |
Returns whether a configuration object exists. Overrides FileStorage:: |
|
InstallStorage:: |
protected | function | Get folder inside each component that contains the files. | |
InstallStorage:: |
public | function | Get all configuration names and folders for a list of modules or themes. | |
InstallStorage:: |
protected | function | Get folder inside Drupal core that contains the files. | |
InstallStorage:: |
public | function | Get all configuration names and folders for Drupal core. | |
InstallStorage:: |
public | function |
Overrides Drupal\Core\Config\FileStorage::getFilePath(). Overrides FileStorage:: |
|
InstallStorage:: |
public | function |
Gets configuration object names starting with a given prefix. Overrides FileStorage:: |
|
InstallStorage:: |
public | function |
Overrides Drupal\Core\Config\FileStorage::rename(). Overrides FileStorage:: |
|
InstallStorage:: |
public | function | Resets the static cache. | |
InstallStorage:: |
public | function |
Overrides Drupal\Core\Config\FileStorage::write(). Overrides FileStorage:: |
|
StorageInterface:: |
constant | The default collection name. |