function StorageBase::get

Same name in other branches
  1. 9 core/lib/Drupal/Core/KeyValueStore/StorageBase.php \Drupal\Core\KeyValueStore\StorageBase::get()
  2. 8.9.x core/lib/Drupal/Core/KeyValueStore/StorageBase.php \Drupal\Core\KeyValueStore\StorageBase::get()
  3. 11.x core/lib/Drupal/Core/KeyValueStore/StorageBase.php \Drupal\Core\KeyValueStore\StorageBase::get()

Overrides KeyValueStoreInterface::get

1 method overrides StorageBase::get()
MemoryStorage::get in core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php
Returns the stored value for a given key.

File

core/lib/Drupal/Core/KeyValueStore/StorageBase.php, line 34

Class

StorageBase
Provides a base class for key/value storage implementations.

Namespace

Drupal\Core\KeyValueStore

Code

public function get($key, $default = NULL) {
    $values = $this->getMultiple([
        $key,
    ]);
    return $values[$key] ?? $default;
}

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