public function CachedStorage::read

Implements Drupal\Core\Config\StorageInterface::read().

Overrides StorageInterface::read

File

drupal/core/lib/Drupal/Core/Config/CachedStorage.php, line 61
Contains Drupal\Core\Config\CachedStorage.

Class

CachedStorage
Defines the cached storage controller.

Namespace

Drupal\Core\Config

Code

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

    // The cache backend supports primitive data types, but only an array
    // represents valid config object data.
    if (is_array($cache->data)) {
      return $cache->data;
    }
  }

  // Read from the storage on a cache miss and cache the data, if any.
  $data = $this->storage
    ->read($name);
  if ($data !== FALSE) {
    $this->cache
      ->set($name, $data, CacheBackendInterface::CACHE_PERMANENT);
  }
  elseif ($cache) {
    $this->cache
      ->delete($name);
  }
  return $data;
}