function DatabaseStorage::readMultiple

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/DatabaseStorage.php \Drupal\Core\Config\DatabaseStorage::readMultiple()
  2. 8.9.x core/lib/Drupal/Core/Config/DatabaseStorage.php \Drupal\Core\Config\DatabaseStorage::readMultiple()
  3. 11.x core/lib/Drupal/Core/Config/DatabaseStorage.php \Drupal\Core\Config\DatabaseStorage::readMultiple()

Overrides StorageInterface::readMultiple

File

core/lib/Drupal/Core/Config/DatabaseStorage.php, line 108

Class

DatabaseStorage
Defines the Database storage.

Namespace

Drupal\Core\Config

Code

public function readMultiple(array $names) {
    if (empty($names)) {
        return [];
    }
    $list = [];
    try {
        $list = $this->connection
            ->query('SELECT [name], [data] FROM {' . $this->connection
            ->escapeTable($this->table) . '} WHERE [collection] = :collection AND [name] IN ( :names[] )', [
            ':collection' => $this->collection,
            ':names[]' => $names,
        ], $this->options)
            ->fetchAllKeyed();
        foreach ($list as &$data) {
            $data = $this->decode($data);
        }
    } catch (\Exception $e) {
        if ($this->connection
            ->schema()
            ->tableExists($this->table)) {
            throw $e;
        }
        // If we attempt a read without actually having the table available,
        // return an empty array so the caller can handle it.
    }
    return $list;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.