public function ConfigProviderInstall::addInstallableConfig in Configuration Provider 8
Same name and namespace in other branches
- 8.2 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 $installable_config storage.
Parameters
\Drupal\config_provider\InMemoryStorage $installable_config: A storage for configuration to be added to.
\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 37
Class
- ConfigProviderInstall
- Class for providing configuration from an install directory.
Namespace
Drupal\config_provider\Plugin\ConfigProviderCode
public function addInstallableConfig(InMemoryStorage $installable_config, array $extensions = []) {
$storage = $this
->getExtensionInstallStorage(static::ID);
$config_names = $this
->listConfig($storage, $extensions);
$config_to_add = $storage
->readMultiple($config_names);
foreach ($config_to_add as $name => $data) {
$installable_config
->write($name, $data);
}
// Get all data from the remaining collections.
// Gather information about all the supported collections.
$collection_info = $this->configManager
->getConfigCollectionInfo();
foreach ($collection_info
->getCollectionNames() as $collection) {
$collection_storage = $storage
->createCollection($collection);
$config_names = $this
->listConfig($collection_storage, $extensions);
$config_to_add = $collection_storage
->readMultiple($config_names);
foreach ($config_to_add as $name => $data) {
$installable_config
->writeToCollection($name, $data, $collection);
}
}
}