public function DatabaseStorage::getAll

public 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

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', array(':collection' => $this->collection));
  $values = array();

  foreach ($result as $item) {
    if ($item) {
      $values[$item->name] = $this->serializer->decode($item->value);
    }
  }
  return $values;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!KeyValueStore!DatabaseStorage.php/function/DatabaseStorage::getAll/8.1.x