W3cubDocs

/Drupal 8

protected function ConfigFactory::doLoadMultiple

protected ConfigFactory::doLoadMultiple(array $names, $immutable = TRUE)

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.

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 = array();

  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)) {
    // Initialise override information.
    $module_overrides = array();
    $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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!ConfigFactory.php/function/ConfigFactory::doLoadMultiple/8.1.x