abstract class StorageBase in Service Container 7
Same name and namespace in other branches
- 7.2 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
- lib/
Drupal/ Core/ KeyValueStore/ StorageBase.php, line 13 - Contains \Drupal\Core\KeyValueStore\StorageBase.
Namespace
Drupal\Core\KeyValueStoreView source
abstract class StorageBase implements KeyValueStoreInterface {
/**
* The name of the collection holding key and value pairs.
*
* @var string
*/
protected $collection;
/**
* Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::__construct().
*/
public function __construct($collection) {
$this->collection = $collection;
}
/**
* Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::getCollectionName().
*/
public function getCollectionName() {
return $this->collection;
}
/**
* Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::get().
*/
public function get($key, $default = NULL) {
$values = $this
->getMultiple(array(
$key,
));
return isset($values[$key]) ? $values[$key] : $default;
}
/**
* Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::setMultiple().
*/
public function setMultiple(array $data) {
foreach ($data as $key => $value) {
$this
->set($key, $value);
}
}
/**
* Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::delete().
*/
public function delete($key) {
$this
->deleteMultiple(array(
$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 |
Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::delete(). Overrides KeyValueStoreInterface:: |
1 |
StorageBase:: |
public | function |
Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::get(). Overrides KeyValueStoreInterface:: |
1 |
StorageBase:: |
public | function |
Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::getCollectionName(). Overrides KeyValueStoreInterface:: |
|
StorageBase:: |
public | function |
Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::setMultiple(). Overrides KeyValueStoreInterface:: |
1 |
StorageBase:: |
public | function | Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::__construct(). | 1 |