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

drivers/config_database/config_database_storage.inc, line 164

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