1 config.inc public ConfigFileStorage::read($name)

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.

Throws

ConfigStorageReadException

Overrides ConfigStorageInterface::read

File

core/includes/config.inc, line 1129
This is the API for configuration storage.

Class

ConfigFileStorage
Defines the file storage controller.

Code

public function read($name) {
  if (!$this->exists($name)) {
    return FALSE;
  }
  $data = file_get_contents($this->getFilePath($name));
  try {
    $data = $this->decode($data);
    // Remove the config name from the read configuration.
    if (isset($data['_config_name'])) {
      unset($data['_config_name']);
    }
  }
  // If an error occurs, catch and rethrow with the file name in the message.
  catch (ConfigStorageException $e) {
    throw new ConfigStorageReadException(format_string("The configuration file \"@filename\" is not properly formatted JSON.\n\nContents:\n<pre>@contents</pre>\n", array('@filename' => $name, '@contents' => $data)));
  }
  return $data;
}