class StorageItem in Express 8
Theme Storage Item.
This is essentially the same object as Storage. The only exception is delegating any data changes to the primary Storage object this StorageItem object lives in.
This storage object can be used in `foreach` loops.
Hierarchy
- class \Drupal\Core\KeyValueStore\StorageBase implements KeyValueStoreInterface
- class \Drupal\Core\KeyValueStore\MemoryStorage
- class \Drupal\bootstrap\Utility\StorageItem implements \Drupal\bootstrap\Utility\Iterator
- class \Drupal\Core\KeyValueStore\MemoryStorage
Expanded class hierarchy of StorageItem
See also
\Drupal\bootstrap\Utility\Storage
1 file declares its use of StorageItem
File
- themes/
contrib/ bootstrap/ src/ Utility/ StorageItem.php, line 24 - Contains \Drupal\bootstrap\Utility\StorageItem.
Namespace
Drupal\bootstrap\UtilityView source
class StorageItem extends MemoryStorage implements \Iterator {
/**
* Flag determining whether or not object has been initialized yet.
*
* @var bool
*/
protected $initialized = FALSE;
/**
* The \Drupal\bootstrap\Storage instance this item belongs to.
*
* @var \Drupal\bootstrap\Utility\Storage
*/
protected $storage;
/**
* {@inheritdoc}
*/
public function __construct($data, Storage $storage) {
$this->storage = $storage;
$this
->setMultiple($data);
$this->initialized = TRUE;
}
/**
* Notifies the main Storage object that data has changed.
*/
public function changed() {
if ($this->initialized) {
$this->storage
->changed();
}
}
/**
* {@inheritdoc}
*/
public function current() {
return current($this->data);
}
/**
* {@inheritdoc}
*/
public function delete($key) {
parent::delete($key);
$this
->changed();
}
/**
* {@inheritdoc}
*/
public function deleteMultiple(array $keys) {
parent::deleteMultiple($keys);
$this
->changed();
}
/**
* {@inheritdoc}
*/
public function deleteAll() {
parent::deleteAll();
$this
->changed();
}
/**
* Determines if the cache is empty.
*
* @return bool
* TRUE or FALSE
*/
public function isEmpty() {
return empty($this->data);
}
/**
* {@inheritdoc}
*/
public function key() {
return key($this->data);
}
/**
* {@inheritdoc}
*/
public function next() {
return next($this->data);
}
/**
* {@inheritdoc}
*/
public function rename($key, $new_key) {
parent::rename($key, $new_key);
$this
->changed();
}
/**
* {@inheritdoc}
*/
public function rewind() {
return reset($this->data);
}
/**
* {@inheritdoc}
*/
public function set($key, $value) {
parent::set($key, $value);
$this
->changed();
}
/**
* {@inheritdoc}
*/
public function setIfNotExists($key, $value) {
if (!isset($this->data[$key])) {
$this->data[$key] = $value;
$this
->changed();
return TRUE;
}
return FALSE;
}
/**
* {@inheritdoc}
*/
public function setMultiple(array $data) {
parent::setMultiple($data);
$this
->changed();
}
/**
* {@inheritdoc}
*/
public function valid() {
return key($this->data) !== NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MemoryStorage:: |
protected | property | The actual storage of key-value pairs. | |
MemoryStorage:: |
public | function |
Returns the stored value for a given key. Overrides StorageBase:: |
|
MemoryStorage:: |
public | function |
Returns all stored key/value pairs in the collection. Overrides KeyValueStoreInterface:: |
|
MemoryStorage:: |
public | function |
Returns the stored key/value pairs for a given set of keys. Overrides KeyValueStoreInterface:: |
|
MemoryStorage:: |
public | function |
Returns whether a given key exists in the store. Overrides KeyValueStoreInterface:: |
|
StorageBase:: |
protected | property | The name of the collection holding key and value pairs. | |
StorageBase:: |
public | function |
Returns the name of this collection. Overrides KeyValueStoreInterface:: |
|
StorageItem:: |
protected | property | Flag determining whether or not object has been initialized yet. | |
StorageItem:: |
protected | property | The \Drupal\bootstrap\Storage instance this item belongs to. | |
StorageItem:: |
public | function | Notifies the main Storage object that data has changed. | |
StorageItem:: |
public | function | ||
StorageItem:: |
public | function |
Deletes an item from the key/value store. Overrides MemoryStorage:: |
|
StorageItem:: |
public | function |
Deletes all items from the key/value store. Overrides MemoryStorage:: |
|
StorageItem:: |
public | function |
Deletes multiple items from the key/value store. Overrides MemoryStorage:: |
|
StorageItem:: |
public | function | Determines if the cache is empty. | |
StorageItem:: |
public | function | ||
StorageItem:: |
public | function | ||
StorageItem:: |
public | function |
Renames a key. Overrides MemoryStorage:: |
|
StorageItem:: |
public | function | ||
StorageItem:: |
public | function |
Saves a value for a given key. Overrides MemoryStorage:: |
|
StorageItem:: |
public | function |
Saves a value for a given key if it does not exist yet. Overrides MemoryStorage:: |
|
StorageItem:: |
public | function |
Saves key/value pairs. Overrides MemoryStorage:: |
|
StorageItem:: |
public | function | ||
StorageItem:: |
public | function |
Overrides StorageBase:: |