You are here

public function DatabaseStorage::getAll in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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 99
Contains \Drupal\Core\KeyValueStore\DatabaseStorage.

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', array(
    ':collection' => $this->collection,
  ));
  $values = array();
  foreach ($result as $item) {
    if ($item) {
      $values[$item->name] = $this->serializer
        ->decode($item->value);
    }
  }
  return $values;
}