protected function ConfigInstaller::getConfigToCreate in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Config/ConfigInstaller.php \Drupal\Core\Config\ConfigInstaller::getConfigToCreate()
- 9 core/lib/Drupal/Core/Config/ConfigInstaller.php \Drupal\Core\Config\ConfigInstaller::getConfigToCreate()
Gets configuration data from the provided storage to create.
Parameters
StorageInterface $storage: The configuration storage to read configuration from.
string $collection: The 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.
Return value
array An array of configuration data read from the source storage keyed by the configuration object name.
File
- core/
lib/ Drupal/ Core/ Config/ ConfigInstaller.php, line 280
Class
Namespace
Drupal\Core\ConfigCode
protected function getConfigToCreate(StorageInterface $storage, $collection, $prefix = '', array $profile_storages = []) {
if ($storage
->getCollectionName() != $collection) {
$storage = $storage
->createCollection($collection);
}
$data = $storage
->readMultiple($storage
->listAll($prefix));
// Check to see if configuration provided by the install profile has any
// overrides.
foreach ($profile_storages as $profile_storage) {
if ($profile_storage
->getCollectionName() != $collection) {
$profile_storage = $profile_storage
->createCollection($collection);
}
$profile_overrides = $profile_storage
->readMultiple(array_keys($data));
if (InstallerKernel::installationAttempted()) {
// During installation overrides of simple configuration are applied
// immediately. Configuration entities that are overridden will be
// updated when the profile is installed. This allows install profiles
// to provide configuration entity overrides that have dependencies that
// cannot be met when the module provided configuration entity is
// created.
foreach ($profile_overrides as $name => $override_data) {
// The only way to determine if they are configuration entities is the
// presence of a dependencies key.
if (!isset($override_data['dependencies'])) {
$data[$name] = $override_data;
}
}
}
else {
// Allow install profiles to provide overridden configuration for new
// extensions that are being enabled after Drupal has already been
// installed. This allows profiles to ship new extensions in version
// updates without requiring additional code to apply the overrides.
$data = $profile_overrides + $data;
}
}
return $data;
}