You are here

class MetadataBag in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/http-foundation/Session/Storage/MetadataBag.php \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag
  2. 8 core/lib/Drupal/Core/Session/MetadataBag.php \Drupal\Core\Session\MetadataBag
Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Session/MetadataBag.php \Drupal\Core\Session\MetadataBag

Provides a container for application specific session metadata.

Hierarchy

Expanded class hierarchy of MetadataBag

1 file declares its use of MetadataBag
CsrfTokenGenerator.php in core/lib/Drupal/Core/Access/CsrfTokenGenerator.php
Contains \Drupal\Core\Access\CsrfTokenGenerator.
1 string reference to 'MetadataBag'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses MetadataBag
session_manager.metadata_bag in core/core.services.yml
Drupal\Core\Session\MetadataBag

File

core/lib/Drupal/Core/Session/MetadataBag.php, line 16
Contains \Drupal\Core\Session\MetadataBag.

Namespace

Drupal\Core\Session
View source
class MetadataBag extends SymfonyMetadataBag {

  /**
   * The key used to store the CSRF token seed in the session.
   */
  const CSRF_TOKEN_SEED = 's';

  /**
   * Constructs a new metadata bag instance.
   *
   * @param \Drupal\Core\Site\Settings $settings
   *   The settings instance.
   */
  public function __construct(Settings $settings) {
    $update_threshold = $settings
      ->get('session_write_interval', 180);
    parent::__construct('_sf2_meta', $update_threshold);
  }

  /**
   * Set the CSRF token seed.
   *
   * @param string $csrf_token_seed
   *   The per-session CSRF token seed.
   */
  public function setCsrfTokenSeed($csrf_token_seed) {
    $this->meta[static::CSRF_TOKEN_SEED] = $csrf_token_seed;
  }

  /**
   * Get the CSRF token seed.
   *
   * @return string|null
   *   The per-session CSRF token seed or null when no value is set.
   */
  public function getCsrfTokenSeed() {
    if (isset($this->meta[static::CSRF_TOKEN_SEED])) {
      return $this->meta[static::CSRF_TOKEN_SEED];
    }
  }

  /**
   * Clear the CSRF token seed.
   */
  public function clearCsrfTokenSeed() {
    unset($this->meta[static::CSRF_TOKEN_SEED]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MetadataBag::$lastUsed private property Unix timestamp.
MetadataBag::$meta protected property
MetadataBag::$name private property
MetadataBag::$storageKey private property
MetadataBag::$updateThreshold private property
MetadataBag::clear public function Clears out data from bag. Overrides SessionBagInterface::clear
MetadataBag::clearCsrfTokenSeed public function Clear the CSRF token seed.
MetadataBag::CREATED constant
MetadataBag::CSRF_TOKEN_SEED constant The key used to store the CSRF token seed in the session.
MetadataBag::getCreated public function Gets the created timestamp metadata.
MetadataBag::getCsrfTokenSeed public function Get the CSRF token seed.
MetadataBag::getLastUsed public function Gets the last used metadata.
MetadataBag::getLifetime public function Gets the lifetime that the session cookie was set with.
MetadataBag::getName public function Gets this bag's name. Overrides SessionBagInterface::getName
MetadataBag::getStorageKey public function Gets the storage key for this bag. Overrides SessionBagInterface::getStorageKey
MetadataBag::initialize public function Initializes the Bag. Overrides SessionBagInterface::initialize
MetadataBag::LIFETIME constant
MetadataBag::setCsrfTokenSeed public function Set the CSRF token seed.
MetadataBag::setName public function Sets name.
MetadataBag::stampCreated private function
MetadataBag::stampNew public function Stamps a new session's metadata.
MetadataBag::UPDATED constant
MetadataBag::__construct public function Constructs a new metadata bag instance. Overrides MetadataBag::__construct