public function DatabaseStorage::read

Implements Drupal\Core\Config\StorageInterface::read().

Throws

PDOException

Drupal\Core\Database\DatabaseExceptionWrapper Only thrown in case $this->options['throw_exception'] is TRUE.

Overrides StorageInterface::read

File

drupal/core/lib/Drupal/Core/Config/DatabaseStorage.php, line 71
Definition of Drupal\Core\Config\DatabaseStorage.

Class

DatabaseStorage
Defines the Database storage controller.

Namespace

Drupal\Core\Config

Code

public function read($name) {
  $data = FALSE;

  // There are situations, like in the installer, where we may attempt a
  // read without actually having the database available. In this case,
  // catch the exception and just return an empty array so the caller can
  // handle it if need be.
  try {
    $raw = $this->connection
      ->query('SELECT data FROM {' . $this->connection
      ->escapeTable($this->table) . '} WHERE name = :name', array(
      ':name' => $name,
    ), $this->options)
      ->fetchField();
    if ($raw !== FALSE) {
      $data = $this
        ->decode($raw);
    }
  } catch (\Exception $e) {
  }
  return $data;
}