public function ConfigProviderInstall::addInstallableConfig in Configuration Provider 8.2
Same name and namespace in other branches
- 8 src/Plugin/ConfigProvider/ConfigProviderInstall.php \Drupal\config_provider\Plugin\ConfigProvider\ConfigProviderInstall::addInstallableConfig()
Adds configuration that is available to be installed or updated.
Not intended to be called an install time, this method instead facilitates determining what configuration updates are available.
Implementing plugins should write configuration as appropriate to the ::providerStorage storage.
Parameters
\Drupal\Core\Extension\Extension[] $extensions: (Optional) An associative array of Extension objects, keyed by extension name. If provided, data loaded will be limited to these extensions.
Overrides ConfigProviderInterface::addInstallableConfig
See also
\Drupal\config_provider\Plugin\ConfigProviderInterface\addConfigToCreate()
File
- src/
Plugin/ ConfigProvider/ ConfigProviderInstall.php, line 36
Class
- ConfigProviderInstall
- Class for providing configuration from an install directory.
Namespace
Drupal\config_provider\Plugin\ConfigProviderCode
public function addInstallableConfig(array $extensions = []) {
$storage = $this
->getExtensionInstallStorage(static::ID);
// Gather information about all the supported collections.
$collection_info = $this->configManager
->getConfigCollectionInfo();
foreach ($collection_info
->getCollectionNames() as $collection) {
if ($storage
->getCollectionName() !== $collection) {
$storage = $storage
->createCollection($collection);
}
$config_names = $this
->listConfig($storage, $extensions);
$data = $storage
->readMultiple($config_names);
// Check to see if the corresponding override storage has any overrides.
foreach ($this
->getProfileStorages() as $profile_storage) {
if ($profile_storage
->getCollectionName() !== $collection) {
$profile_storage = $profile_storage
->createCollection($collection);
}
$data = $profile_storage
->readMultiple(array_keys($data)) + $data;
}
foreach ($data as $name => $value) {
if ($this->providerStorage
->getCollectionName() !== $collection) {
$this->providerStorage = $this->providerStorage
->createCollection($collection);
}
$value = $this
->addDefaultConfigHash($value);
$this->providerStorage
->write($name, $value);
}
}
}