You are here

class Drupal8State in Rocket.Chat 8.2

Class Drupal8State

@package Drupal\rocket_chat_api\RocketChat connects the RocketChat State with the Drupal State (not an implementation but a proxy for state.

Hierarchy

Expanded class hierarchy of Drupal8State

6 files declare their use of Drupal8State
Channel.php in modules/rocket_chat_api/src/RocketChat/Element/Channel.php
GroupChannel.php in modules/rocket_chat_group/src/Plugin/Field/FieldType/GroupChannel.php
moduleHelper.php in modules/rocket_chat_group/src/RocketChat/moduleHelper.php
RocketChatChannelBlock.php in modules/rocket_chat_group/src/Plugin/Block/RocketChatChannelBlock.php
RocketChatGroupHelper.php in src/Form/RocketChatGroupHelper.php

... See full list

File

modules/rocket_chat_api/src/RocketChat/Drupal8State.php, line 15

Namespace

Drupal\rocket_chat_api\RocketChat
View source
class Drupal8State implements RocketChatStateinterface, StateInterface {

  /**
   * @var \Drupal\Core\State\StateInterface
   */
  private $state;
  public function __construct(StateInterface $state) {
    $this->state = $state;
  }

  /**
   * 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) {
    return $this->state
      ->get($key, $default);
  }

  /**
   * 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) {
    return $this->state
      ->getMultiple($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) {
    return $this->state
      ->set($key, $value);
  }

  /**
   * Saves key/value pairs.
   *
   * @param array $data
   *   An associative array of key/value pairs.
   */
  public function setMultiple(array $data) {
    return $this->state
      ->setMultiple($data);
  }

  /**
   * Deletes an item.
   *
   * @param string $key
   *   The item name to delete.
   */
  public function delete($key) {
    return $this->state
      ->delete($key);
  }

  /**
   * Deletes multiple items.
   *
   * @param array $keys
   *   A list of item names to delete.
   */
  public function deleteMultiple(array $keys) {
    return $this->state
      ->deleteMultiple($keys);
  }

  /**
   * Resets the static cache.
   *
   * This is mainly used in testing environments.
   */
  public function resetCache() {
    return $this->state
      ->resetCache();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Drupal8State::$state private property
Drupal8State::delete public function Deletes an item. Overrides RocketChatStateinterface::delete
Drupal8State::deleteMultiple public function Deletes multiple items. Overrides RocketChatStateinterface::deleteMultiple
Drupal8State::get public function Returns the stored value for a given key. Overrides RocketChatStateinterface::get
Drupal8State::getMultiple public function Returns the stored key/value pairs for a given set of keys. Overrides RocketChatStateinterface::getMultiple
Drupal8State::resetCache public function Resets the static cache. Overrides RocketChatStateinterface::resetCache
Drupal8State::set public function Saves a value for a given key. Overrides RocketChatStateinterface::set
Drupal8State::setMultiple public function Saves key/value pairs. Overrides RocketChatStateinterface::setMultiple
Drupal8State::__construct public function