abstract class StorageBase in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/KeyValueStore/StorageBase.php \Drupal\Core\KeyValueStore\StorageBase
Provides a base class for key/value storage implementations.
Hierarchy
- class \Drupal\Core\KeyValueStore\StorageBase implements KeyValueStoreInterface
Expanded class hierarchy of StorageBase
File
- core/
lib/ Drupal/ Core/ KeyValueStore/ StorageBase.php, line 8
Namespace
Drupal\Core\KeyValueStoreView source
abstract class StorageBase implements KeyValueStoreInterface {
/**
* The name of the collection holding key and value pairs.
*
* @var string
*/
protected $collection;
/**
* {@inheritdoc}
*/
public function __construct($collection) {
$this->collection = $collection;
}
/**
* {@inheritdoc}
*/
public function getCollectionName() {
return $this->collection;
}
/**
* {@inheritdoc}
*/
public function get($key, $default = NULL) {
$values = $this
->getMultiple([
$key,
]);
return isset($values[$key]) ? $values[$key] : $default;
}
/**
* {@inheritdoc}
*/
public function setMultiple(array $data) {
foreach ($data as $key => $value) {
$this
->set($key, $value);
}
}
/**
* {@inheritdoc}
*/
public function delete($key) {
$this
->deleteMultiple([
$key,
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
KeyValueStoreInterface:: |
public | function | Deletes all items from the key/value store. | 3 |
KeyValueStoreInterface:: |
public | function | Deletes multiple items from the key/value store. | 3 |
KeyValueStoreInterface:: |
public | function | Returns all stored key/value pairs in the collection. | 3 |
KeyValueStoreInterface:: |
public | function | Returns the stored key/value pairs for a given set of keys. | 3 |
KeyValueStoreInterface:: |
public | function | Returns whether a given key exists in the store. | 3 |
KeyValueStoreInterface:: |
public | function | Renames a key. | 3 |
KeyValueStoreInterface:: |
public | function | Saves a value for a given key. | 3 |
KeyValueStoreInterface:: |
public | function | Saves a value for a given key if it does not exist yet. | 3 |
StorageBase:: |
protected | property | The name of the collection holding key and value pairs. | |
StorageBase:: |
public | function |
Deletes an item from the key/value store. Overrides KeyValueStoreInterface:: |
1 |
StorageBase:: |
public | function |
Returns the stored value for a given key. Overrides KeyValueStoreInterface:: |
1 |
StorageBase:: |
public | function |
Returns the name of this collection. Overrides KeyValueStoreInterface:: |
|
StorageBase:: |
public | function |
Saves key/value pairs. Overrides KeyValueStoreInterface:: |
1 |
StorageBase:: |
public | function | 1 |