function ConfigFactory::doLoadMultiple

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Config/ConfigFactory.php \Drupal\Core\Config\ConfigFactory::doLoadMultiple()
  2. 10 core/lib/Drupal/Core/Config/ConfigFactory.php \Drupal\Core\Config\ConfigFactory::doLoadMultiple()
  3. 11.x core/lib/Drupal/Core/Config/ConfigFactory.php \Drupal\Core\Config\ConfigFactory::doLoadMultiple()

Returns a list of configuration objects for the given names.

Parameters

array $names: List of names of configuration objects.

bool $immutable: (optional) Create an immutable configuration objects. Defaults to TRUE.

Return value

\Drupal\Core\Config\Config[]|\Drupal\Core\Config\ImmutableConfig[] List of successfully loaded configuration objects, keyed by name.

2 calls to ConfigFactory::doLoadMultiple()
ConfigFactory::doGet in core/lib/Drupal/Core/Config/ConfigFactory.php
Returns a configuration object for a given name.
ConfigFactory::loadMultiple in core/lib/Drupal/Core/Config/ConfigFactory.php
Returns a list of configuration objects for the given names.

File

core/lib/Drupal/Core/Config/ConfigFactory.php, line 150

Class

ConfigFactory
Defines the configuration object factory.

Namespace

Drupal\Core\Config

Code

protected function doLoadMultiple(array $names, $immutable = TRUE) {
    $list = [];
    foreach ($names as $key => $name) {
        $cache_key = $this->getConfigCacheKey($name, $immutable);
        if (isset($this->cache[$cache_key])) {
            $list[$name] = $this->cache[$cache_key];
            unset($names[$key]);
        }
    }
    // Pre-load remaining configuration files.
    if (!empty($names)) {
        // Initialize override information.
        $module_overrides = [];
        $storage_data = $this->storage
            ->readMultiple($names);
        if ($immutable && !empty($storage_data)) {
            // Only get module overrides if we have configuration to override.
            $module_overrides = $this->loadOverrides($names);
        }
        foreach ($storage_data as $name => $data) {
            $cache_key = $this->getConfigCacheKey($name, $immutable);
            $this->cache[$cache_key] = $this->createConfigObject($name, $immutable);
            $this->cache[$cache_key]
                ->initWithData($data);
            if ($immutable) {
                if (isset($module_overrides[$name])) {
                    $this->cache[$cache_key]
                        ->setModuleOverride($module_overrides[$name]);
                }
                if (isset($GLOBALS['config'][$name])) {
                    $this->cache[$cache_key]
                        ->setSettingsOverride($GLOBALS['config'][$name]);
                }
            }
            $this->propagateConfigOverrideCacheability($cache_key, $name);
            $list[$name] = $this->cache[$cache_key];
        }
    }
    return $list;
}

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