function DatabaseStorage::getAll

Same name in other branches
  1. 9 core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php \Drupal\Core\KeyValueStore\DatabaseStorage::getAll()
  2. 10 core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php \Drupal\Core\KeyValueStore\DatabaseStorage::getAll()
  3. 11.x core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php \Drupal\Core\KeyValueStore\DatabaseStorage::getAll()

Overrides KeyValueStoreInterface::getAll

1 method overrides DatabaseStorage::getAll()
DatabaseStorageExpirable::getAll in core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php
Returns all stored key/value pairs in the collection.

File

core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php, line 94

Class

DatabaseStorage
Defines a default key/value store implementation.

Namespace

Drupal\Core\KeyValueStore

Code

public function getAll() {
    $result = $this->connection
        ->query('SELECT name, value FROM {' . $this->connection
        ->escapeTable($this->table) . '} WHERE collection = :collection', [
        ':collection' => $this->collection,
    ]);
    $values = [];
    foreach ($result as $item) {
        if ($item) {
            $values[$item->name] = $this->serializer
                ->decode($item->value);
        }
    }
    return $values;
}

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