State::__construct

State::__construct(KeyValueFactoryInterface $key_value_factory) Constructs a State object. Parameters \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory: The key value store to use. File core/lib/Drupal/Core/State/State.php, line 32 Class State Provides the state system using a key value store. Namespace Drupal\Core\State Code function __construct(KeyValueFactoryInterface $key_value_factory) { $this->keyValueStore = $key_value_factory->get('state'); }

StateInterface::delete

public StateInterface::delete($key) Deletes an item. Parameters string $key: The item name to delete. File core/lib/Drupal/Core/State/StateInterface.php, line 60 Class StateInterface Defines the interface for the state system. Namespace Drupal\Core\State Code public function delete($key);

StateInterface

Defines the interface for the state system. Hierarchy interface \Drupal\Core\State\StateInterface Related topics State API Information about the State API. File core/lib/Drupal/Core/State/StateInterface.php, line 10 Namespace Drupal\Core\State Members Name Modifiers Type Description StateInterface::delete public function Deletes an item. StateInterface::deleteMultiple public function Deletes multiple items. StateInterface::get public function Returns th

StateInterface::deleteMultiple

public StateInterface::deleteMultiple(array $keys) Deletes multiple items. Parameters array $keys: A list of item names to delete. File core/lib/Drupal/Core/State/StateInterface.php, line 68 Class StateInterface Defines the interface for the state system. Namespace Drupal\Core\State Code public function deleteMultiple(array $keys);

State::getMultiple

public State::getMultiple(array $keys) Returns the stored key/value pairs for a given set of keys. Parameters array $keys: A list of keys to retrieve. Return value array An associative array of items successfully returned, indexed by key. Overrides StateInterface::getMultiple File core/lib/Drupal/Core/State/State.php, line 47 Class State Provides the state system using a key value store. Namespace Drupal\Core\State Code public function getMultiple(array $keys) { $values = array();

State::resetCache

public State::resetCache() Resets the static cache. This is mainly used in testing environments. Overrides StateInterface::resetCache File core/lib/Drupal/Core/State/State.php, line 117 Class State Provides the state system using a key value store. Namespace Drupal\Core\State Code public function resetCache() { $this->cache = array(); }

State::get

public State::get($key, $default = NULL) Returns the stored value for a given key. Parameters string $key: The key of the data to retrieve. mixed $default: The default value to use if the key is not found. Return value mixed The stored value, or NULL if no value exists. Overrides StateInterface::get File core/lib/Drupal/Core/State/State.php, line 39 Class State Provides the state system using a key value store. Namespace Drupal\Core\State Code public function get($key, $default = NUL

State::set

public State::set($key, $value) Saves a value for a given key. Parameters string $key: The key of the data to store. mixed $value: The data to store. Overrides StateInterface::set File core/lib/Drupal/Core/State/State.php, line 82 Class State Provides the state system using a key value store. Namespace Drupal\Core\State Code public function set($key, $value) { $this->cache[$key] = $value; $this->keyValueStore->set($key, $value); }

State::setMultiple

public State::setMultiple(array $data) Saves key/value pairs. Parameters array $data: An associative array of key/value pairs. Overrides StateInterface::setMultiple File core/lib/Drupal/Core/State/State.php, line 90 Class State Provides the state system using a key value store. Namespace Drupal\Core\State Code public function setMultiple(array $data) { foreach ($data as $key => $value) { $this->cache[$key] = $value; } $this->keyValueStore->setMultiple($data); }

State::$keyValueStore

The key value store to use. Type: \Drupal\Core\KeyValueStore\KeyValueStoreInterface File core/lib/Drupal/Core/State/State.php, line 17 Class State Provides the state system using a key value store. Namespace Drupal\Core\State Code protected $keyValueStore;