function FileStorage::read
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Config/FileStorage.php \Drupal\Core\Config\FileStorage::read()
- 10 core/lib/Drupal/Core/Config/FileStorage.php \Drupal\Core\Config\FileStorage::read()
- 9 core/lib/Drupal/Core/Config/FileStorage.php \Drupal\Core\Config\FileStorage::read()
- 8.9.x core/lib/Drupal/Core/Config/FileStorage.php \Drupal\Core\Config\FileStorage::read()
Implements Drupal\Core\Config\StorageInterface::read().
Parameters
string $name: The name of a configuration object to load.
Return value
array|false The configuration data stored for the configuration object name. If no configuration data exists for the given name, FALSE is returned.
Throws
\Drupal\Core\Config\UnsupportedDataTypeConfigException
Overrides StorageInterface::read
1 call to FileStorage::read()
- FileStorage::readMultiple in core/
lib/ Drupal/ Core/ Config/ FileStorage.php - Reads configuration data from the storage.
File
-
core/
lib/ Drupal/ Core/ Config/ FileStorage.php, line 87
Class
- FileStorage
- Defines the file storage.
Namespace
Drupal\Core\ConfigCode
public function read($name) {
if (!$this->exists($name)) {
return FALSE;
}
$filepath = $this->getFilePath($name);
// To support enums in YAML files, the config system implements a special
// autoloader to load classes from extensions that may not be installed such
// as before config sync. This autoloader has to be primed with the names of
// extensions which are about to be installed. However, before doing that,
// it has to read the extensions from core.extension. To avoid trying to
// unserialize() enums which may not exist, avoid the YamlCacheCollector
// when reading core.extension, this allows the autoloader to be set up
// prior to the cache being unserialized.
try {
if ($name === 'core.extension') {
$data = file_get_contents($filepath);
return Yaml::decode($data);
}
elseif ($data = $this->yamlCacheCollector
->get($filepath)) {
return is_array($data) ? $data : FALSE;
}
} catch (InvalidDataTypeException $e) {
throw new UnsupportedDataTypeConfigException('Invalid data type in config ' . $name . ', found in file ' . $filepath . ': ' . $e->getMessage());
}
return $data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.