1 config.inc public ConfigDatabaseStorage::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 1394
This is the API for configuration storage.

Class

ConfigDatabaseStorage
Defines the database storage controller.

Code

public function read($name) {
  if (!$this->exists($name)) {
    return FALSE;
  }
  $data = db_select($this->table, 'c', array('target' => $this->database))
    ->fields('c', array('data'))
    ->condition('c.name', $name)
    ->execute()
    ->fetchField();
  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;
}