You are here

public function CachedStorage::read in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Config/CachedStorage.php \Drupal\Core\Config\CachedStorage::read()

Reads configuration data from the storage.

Parameters

string $name: The name of a configuration object to load.

Return value

array|bool The configuration data stored for the configuration object name. If no configuration data exists for the given name, FALSE is returned.

Overrides StorageInterface::read

File

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

Class

CachedStorage
Defines the cached storage.

Namespace

Drupal\Core\Config

Code

public function read($name) {
  $cache_key = $this
    ->getCacheKey($name);
  if ($cache = $this->cache
    ->get($cache_key)) {

    // The cache contains either the cached configuration data or FALSE
    // if the configuration file does not exist.
    return $cache->data;
  }

  // Read from the storage on a cache miss and cache the data. Also cache
  // information about missing configuration objects.
  $data = $this->storage
    ->read($name);
  $this->cache
    ->set($cache_key, $data);
  return $data;
}