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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.