You are here

public function DatabaseStorage::getAll in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php \Drupal\Core\KeyValueStore\DatabaseStorage::getAll()

Returns all stored key/value pairs in the collection.

Return value

array An associative array containing all stored items in the collection.

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