1.20.x config_file_storage.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

drivers/config_file/config_file_storage.inc, line 97

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;
}