function ConfigInstaller::getConfigToCreate

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/ConfigInstaller.php \Drupal\Core\Config\ConfigInstaller::getConfigToCreate()
  2. 10 core/lib/Drupal/Core/Config/ConfigInstaller.php \Drupal\Core\Config\ConfigInstaller::getConfigToCreate()
  3. 11.x 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.

3 calls to ConfigInstaller::getConfigToCreate()
ConfigInstaller::findDefaultConfigWithUnmetDependencies in core/lib/Drupal/Core/Config/ConfigInstaller.php
Finds default configuration with unmet dependencies.
ConfigInstaller::findPreExistingConfiguration in core/lib/Drupal/Core/Config/ConfigInstaller.php
Finds pre-existing configuration objects for the provided extension.
ConfigInstaller::installDefaultConfig in core/lib/Drupal/Core/Config/ConfigInstaller.php
Installs the default configuration of a given extension.

File

core/lib/Drupal/Core/Config/ConfigInstaller.php, line 267

Class

ConfigInstaller

Namespace

Drupal\Core\Config

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.