You are here

public function FileStorage::read in Drupal 10

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

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

Throws

\Drupal\Core\Config\UnsupportedDataTypeConfigException

File

core/lib/Drupal/Core/Config/FileStorage.php, line 103

Class

FileStorage
Defines the file storage.

Namespace

Drupal\Core\Config

Code

public function read($name) {
  if (!$this
    ->exists($name)) {
    return FALSE;
  }
  $filepath = $this
    ->getFilePath($name);
  if ($data = $this->fileCache
    ->get($filepath)) {
    return $data;
  }
  $data = file_get_contents($filepath);
  try {
    $data = $this
      ->decode($data);
  } catch (InvalidDataTypeException $e) {
    throw new UnsupportedDataTypeConfigException('Invalid data type in config ' . $name . ', found in file ' . $filepath . ': ' . $e
      ->getMessage());
  }
  $this->fileCache
    ->set($filepath, $data);
  return $data;
}