class FeaturesExtensionStorages in Features 8.3
Same name and namespace in other branches
- 8.4 src/FeaturesExtensionStorages.php \Drupal\features\FeaturesExtensionStorages
Wraps FeaturesInstallStorage to support multiple configuration directories.
Hierarchy
- class \Drupal\features\FeaturesExtensionStorages implements FeaturesExtensionStoragesInterface
Expanded class hierarchy of FeaturesExtensionStorages
File
- src/
FeaturesExtensionStorages.php, line 12
Namespace
Drupal\featuresView source
class FeaturesExtensionStorages implements FeaturesExtensionStoragesInterface {
/**
* The target storage.
*
* @var \Drupal\Core\Config\StorageInterface
*/
protected $configStorage;
/**
* The extension storages.
*
* @var \Drupal\Core\Config\StorageInterface[]
*/
protected $extensionStorages;
/**
* Configuration provided by extension storages.
*
* @var array
*/
protected $configurationLists;
/**
* Constructs a new FeaturesExtensionStorages object.
*
* @param \Drupal\Core\Config\StorageInterface $config_storage
* The configuration storage.
*/
public function __construct(StorageInterface $config_storage) {
$this->configStorage = $config_storage;
}
/**
* {@inheritdoc}
*/
public function getExtensionStorages() {
return $this->extensionStorages;
}
/**
* {@inheritdoc}
*/
public function addStorage($directory = InstallStorage::CONFIG_INSTALL_DIRECTORY) {
$this->extensionStorages[$directory] = new FeaturesInstallStorage($this->configStorage, $directory);
$this
->reset();
}
/**
* {@inheritdoc}
*/
public function read($name) {
$list = $this
->listAllByDirectory('');
if (isset($list[$name])) {
$directory = $list[$name];
return $this->extensionStorages[$directory]
->read($name);
}
return FALSE;
}
/**
* {@inheritdoc}
*/
public function listAll($prefix = '') {
return array_keys($this
->listAllByDirectory($prefix));
}
/**
* {@inheritdoc}
*/
public function listExtensionConfig(Extension $extension) {
$extension_config = [];
foreach ($this->extensionStorages as $directory => $extension_storage) {
$extension_config = array_merge($extension_config, array_keys($extension_storage
->getComponentNames([
$extension
->getName() => $extension,
])));
}
return $extension_config;
}
/**
* Resets packages and configuration assignment.
*/
protected function reset() {
$this->configurationLists = [];
}
/**
* Returns a list of all configuration available from extensions.
*
* @param string $prefix
* (optional) The prefix to search for. If omitted, all configuration object
* names that exist are returned.
*
* @return array
* An array with configuration item names as keys and configuration
* directories as values.
*/
protected function listAllByDirectory($prefix = '') {
if (!isset($this->configurationLists[$prefix])) {
$this->configurationLists[$prefix] = [];
foreach ($this->extensionStorages as $directory => $extension_storage) {
$this->configurationLists[$prefix] += array_fill_keys($extension_storage
->listAll($prefix), $directory);
}
}
return $this->configurationLists[$prefix];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeaturesExtensionStorages:: |
protected | property | The target storage. | |
FeaturesExtensionStorages:: |
protected | property | Configuration provided by extension storages. | |
FeaturesExtensionStorages:: |
protected | property | The extension storages. | |
FeaturesExtensionStorages:: |
public | function |
Adds a storage. Overrides FeaturesExtensionStoragesInterface:: |
|
FeaturesExtensionStorages:: |
public | function |
Returns all registered extension storages. Overrides FeaturesExtensionStoragesInterface:: |
|
FeaturesExtensionStorages:: |
public | function |
Gets configuration object names starting with a given prefix. Overrides FeaturesExtensionStoragesInterface:: |
|
FeaturesExtensionStorages:: |
protected | function | Returns a list of all configuration available from extensions. | 1 |
FeaturesExtensionStorages:: |
public | function |
Lists names of configuration objects provided by a given extension. Overrides FeaturesExtensionStoragesInterface:: |
|
FeaturesExtensionStorages:: |
public | function |
Reads configuration data from the storages. Overrides FeaturesExtensionStoragesInterface:: |
|
FeaturesExtensionStorages:: |
protected | function | Resets packages and configuration assignment. | |
FeaturesExtensionStorages:: |
public | function | Constructs a new FeaturesExtensionStorages object. |