CachedStorage::readMultiple

public CachedStorage::readMultiple(array $names)

Reads configuration data from the storage.

Parameters

array $names: List of names of the configuration objects to load.

Return value

array A list of the configuration data stored for the configuration object name that could be loaded for the passed list of names.

Overrides StorageInterface::readMultiple

File

core/lib/Drupal/Core/Config/CachedStorage.php, line 82

Class

CachedStorage
Defines the cached storage.

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
public function readMultiple(array $names) {
  $data_to_return = array();
 
  $cache_keys_map = $this->getCacheKeys($names);
  $cache_keys = array_values($cache_keys_map);
  $cached_list = $this->cache->getMultiple($cache_keys);
 
  if (!empty($cache_keys)) {
    // $cache_keys_map contains the full $name => $cache_key map, while
    // $cache_keys contains just the $cache_key values that weren't found in
    // the cache.
    // @see \Drupal\Core\Cache\CacheBackendInterface::getMultiple()
    $names_to_get = array_keys(array_intersect($cache_keys_map, $cache_keys));
    $list = $this->storage->readMultiple($names_to_get);
    // Cache configuration objects that were loaded from the storage, cache
    // missing configuration objects as an explicit FALSE.
    $items = array();
    foreach ($names_to_get as $name) {
      $data = isset($list[$name]) ? $list[$name] : FALSE;
      $data_to_return[$name] = $data;
      $items[$cache_keys_map[$name]] = array('data' => $data);
    }
 
    $this->cache->setMultiple($items);
  }
 
  // Add the configuration objects from the cache to the list.
  $cache_keys_inverse_map = array_flip($cache_keys_map);
  foreach ($cached_list as $cache_key => $cache) {
    $name = $cache_keys_inverse_map[$cache_key];
    $data_to_return[$name] = $cache->data;
  }
 
  // Ensure that only existing configuration objects are returned, filter out
  // cached information about missing objects.
  return array_filter($data_to_return);
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.