You are here

class StateWrapper in Devel 8.2

Same name and namespace in other branches
  1. 8.3 webprofiler/src/State/StateWrapper.php \Drupal\webprofiler\State\StateWrapper
  2. 8 webprofiler/src/State/StateWrapper.php \Drupal\webprofiler\State\StateWrapper
  3. 4.x webprofiler/src/State/StateWrapper.php \Drupal\webprofiler\State\StateWrapper

Class StateWrapper.

Hierarchy

Expanded class hierarchy of StateWrapper

1 string reference to 'StateWrapper'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses StateWrapper
webprofiler.debug.state in webprofiler/webprofiler.services.yml
Drupal\webprofiler\State\StateWrapper

File

webprofiler/src/State/StateWrapper.php, line 12

Namespace

Drupal\webprofiler\State
View source
class StateWrapper extends CacheCollector implements StateInterface {

  /**
   * The system state.
   *
   * @var \Drupal\Core\State\StateInterface
   */
  private $state;

  /**
   * The state data collector.
   *
   * @var \Drupal\webprofiler\DataCollector\StateDataCollector
   */
  private $dataCollector;

  /**
   * StateWrapper constructor.
   *
   * @param \Drupal\Core\State\StateInterface $state
   *   The system state.
   * @param \Drupal\webprofiler\DataCollector\StateDataCollector $dataCollector
   *   The state data collector.
   */
  public function __construct(StateInterface $state, StateDataCollector $dataCollector) {
    $this->state = $state;
    $this->dataCollector = $dataCollector;
  }

  /**
   * {@inheritdoc}
   */
  public function get($key, $default = NULL) {
    $this->dataCollector
      ->addState($key);
    return $this->state
      ->get($key, $default);
  }

  /**
   * {@inheritdoc}
   */
  public function getMultiple(array $keys) {
    foreach ($keys as $key) {
      $this->dataCollector
        ->addState($key);
    }
    return $this->state
      ->getMultiple($keys);
  }

  /**
   * {@inheritdoc}
   */
  public function set($key, $value) {
    $this->state
      ->set($key, $value);
  }

  /**
   * {@inheritdoc}
   */
  public function setMultiple(array $data) {
    $this->state
      ->setMultiple($data);
  }

  /**
   * {@inheritdoc}
   */
  public function delete($key) {
    $this->state
      ->delete($key);
  }

  /**
   * {@inheritdoc}
   */
  public function deleteMultiple(array $keys) {
    $this->state
      ->deleteMultiple($keys);
  }

  /**
   * {@inheritdoc}
   */
  public function resetCache() {
    $this->state
      ->resetCache();
  }

  /**
   * {@inheritdoc}
   */
  protected function resolveCacheMiss($key) {
    return $this->state
      ->resolveCacheMiss($key);
  }

  /**
   * {@inheritdoc}
   */
  public function destruct() {
    $this
      ->updateCache();
  }

  /**
   * Passes through all non-tracked calls onto the decorated object.
   *
   * @param string $method
   *   The called method.
   * @param mixed $args
   *   The passed in arguments.
   *
   * @return mixed
   *   The return argument of the call.
   */
  public function __call($method, $args) {
    return call_user_func_array([
      $this->state,
      $method,
    ], $args);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheCollector::$cache protected property The cache backend that should be used. 1
CacheCollector::$cacheCreated protected property Stores the cache creation time.
CacheCollector::$cacheInvalidated protected property Flag that indicates of the cache has been invalidated.
CacheCollector::$cacheLoaded protected property Indicates if the collected cache was already loaded.
CacheCollector::$cid protected property The cache id that is used for the cache entry.
CacheCollector::$keysToPersist protected property An array of keys to add to the cache on service termination.
CacheCollector::$keysToRemove protected property An array of keys to remove from the cache on service termination.
CacheCollector::$lock protected property The lock backend that should be used. 1
CacheCollector::$storage protected property Storage for the data itself.
CacheCollector::$tags protected property A list of tags that are used for the cache entry.
CacheCollector::clear public function Clears the collected cache entry. Overrides CacheCollectorInterface::clear 1
CacheCollector::getCid protected function Gets the cache ID. 3
CacheCollector::has public function Returns whether data exists for this key. Overrides CacheCollectorInterface::has 1
CacheCollector::invalidateCache protected function Invalidate the cache.
CacheCollector::lazyLoadCache protected function Loads the cache if not already done. 1
CacheCollector::normalizeLockName protected function Normalizes a cache ID in order to comply with database limitations.
CacheCollector::persist protected function Flags an offset value to be written to the persistent cache.
CacheCollector::reset public function Resets the local cache. Overrides CacheCollectorInterface::reset 1
CacheCollector::updateCache protected function Writes a value to the persistent cache immediately. 1
StateWrapper::$dataCollector private property The state data collector.
StateWrapper::$state private property The system state.
StateWrapper::delete public function Deletes an item. Overrides CacheCollector::delete
StateWrapper::deleteMultiple public function Deletes multiple items. Overrides StateInterface::deleteMultiple
StateWrapper::destruct public function Performs destruct operations. Overrides CacheCollector::destruct
StateWrapper::get public function Returns the stored value for a given key. Overrides CacheCollector::get
StateWrapper::getMultiple public function Returns the stored key/value pairs for a given set of keys. Overrides StateInterface::getMultiple
StateWrapper::resetCache public function Resets the static cache. Overrides StateInterface::resetCache
StateWrapper::resolveCacheMiss protected function Resolves a cache miss. Overrides CacheCollector::resolveCacheMiss
StateWrapper::set public function Implements \Drupal\Core\Cache\CacheCollectorInterface::set(). Overrides CacheCollector::set
StateWrapper::setMultiple public function Saves key/value pairs. Overrides StateInterface::setMultiple
StateWrapper::__call public function Passes through all non-tracked calls onto the decorated object.
StateWrapper::__construct public function StateWrapper constructor. Overrides CacheCollector::__construct