interface StateInterface

Same name in this branch
  1. 8.9.x core/modules/workflows/src/StateInterface.php \Drupal\workflows\StateInterface
Same name in other branches
  1. 9 core/modules/workflows/src/StateInterface.php \Drupal\workflows\StateInterface
  2. 9 core/lib/Drupal/Core/State/StateInterface.php \Drupal\Core\State\StateInterface
  3. 10 core/modules/workflows/src/StateInterface.php \Drupal\workflows\StateInterface
  4. 10 core/lib/Drupal/Core/State/StateInterface.php \Drupal\Core\State\StateInterface
  5. 11.x core/modules/workflows/src/StateInterface.php \Drupal\workflows\StateInterface
  6. 11.x core/lib/Drupal/Core/State/StateInterface.php \Drupal\Core\State\StateInterface

Defines the interface for the state system.

Hierarchy

Expanded class hierarchy of StateInterface

All classes that implement StateInterface

Related topics

74 files declare their use of StateInterface
AliasWhitelist.php in core/lib/Drupal/Core/Path/AliasWhitelist.php
AutomatedCron.php in core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php
BrokenInboundPathProcessor.php in core/modules/system/tests/modules/update_script_test/src/PathProcessor/BrokenInboundPathProcessor.php
CacheableMetadataCalculationTest.php in core/modules/views/tests/modules/views_test_cacheable_metadata_calculation/src/Plugin/views/access/CacheableMetadataCalculationTest.php
CKEditor.php in core/modules/ckeditor/src/Plugin/Editor/CKEditor.php

... See full list

File

core/lib/Drupal/Core/State/StateInterface.php, line 10

Namespace

Drupal\Core\State
View source
interface StateInterface {
    
    /**
     * Returns the stored value for a given key.
     *
     * @param string $key
     *   The key of the data to retrieve.
     * @param mixed $default
     *   The default value to use if the key is not found.
     *
     * @return mixed
     *   The stored value, or NULL if no value exists.
     */
    public function get($key, $default = NULL);
    
    /**
     * Returns the stored key/value pairs for a given set of keys.
     *
     * @param array $keys
     *   A list of keys to retrieve.
     *
     * @return array
     *   An associative array of items successfully returned, indexed by key.
     */
    public function getMultiple(array $keys);
    
    /**
     * Saves a value for a given key.
     *
     * @param string $key
     *   The key of the data to store.
     * @param mixed $value
     *   The data to store.
     */
    public function set($key, $value);
    
    /**
     * Saves key/value pairs.
     *
     * @param array $data
     *   An associative array of key/value pairs.
     */
    public function setMultiple(array $data);
    
    /**
     * Deletes an item.
     *
     * @param string $key
     *   The item name to delete.
     */
    public function delete($key);
    
    /**
     * Deletes multiple items.
     *
     * @param array $keys
     *   A list of item names to delete.
     */
    public function deleteMultiple(array $keys);
    
    /**
     * Resets the static cache.
     *
     * This is mainly used in testing environments.
     */
    public function resetCache();

}

Members

Title Sort descending Modifiers Object type Summary Overrides
StateInterface::delete public function Deletes an item. 1
StateInterface::deleteMultiple public function Deletes multiple items. 1
StateInterface::get public function Returns the stored value for a given key. 1
StateInterface::getMultiple public function Returns the stored key/value pairs for a given set of keys. 1
StateInterface::resetCache public function Resets the static cache. 1
StateInterface::set public function Saves a value for a given key. 1
StateInterface::setMultiple public function Saves key/value pairs. 1

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