You are here

class PrivateTempStoreFactory in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/PrivateTempStoreFactory.php \Drupal\user\PrivateTempStoreFactory

Creates a PrivateTempStore object for a given collection.

Hierarchy

Expanded class hierarchy of PrivateTempStoreFactory

8 files declare their use of PrivateTempStoreFactory
CancelUser.php in core/modules/user/src/Plugin/Action/CancelUser.php
Contains \Drupal\user\Plugin\Action\CancelUser.
DeleteMultiple.php in core/modules/node/src/Form/DeleteMultiple.php
Contains \Drupal\node\Form\DeleteMultiple.
DeleteNode.php in core/modules/node/src/Plugin/Action/DeleteNode.php
Contains \Drupal\node\Plugin\Action\DeleteNode.
NodeForm.php in core/modules/node/src/NodeForm.php
Contains \Drupal\node\NodeForm.
NodePreviewConverter.php in core/modules/node/src/ParamConverter/NodePreviewConverter.php
Contains \Drupal\node\ParamConverter\NodePreviewConverter.

... See full list

1 string reference to 'PrivateTempStoreFactory'
user.services.yml in core/modules/user/user.services.yml
core/modules/user/user.services.yml
1 service uses PrivateTempStoreFactory
user.private_tempstore in core/modules/user/user.services.yml
Drupal\user\PrivateTempStoreFactory

File

core/modules/user/src/PrivateTempStoreFactory.php, line 18
Contains \Drupal\user\PrivateTempStoreFactory.

Namespace

Drupal\user
View source
class PrivateTempStoreFactory {

  /**
   * The storage factory creating the backend to store the data.
   *
   * @var \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface
   */
  protected $storageFactory;

  /**
   * The lock object used for this data.
   *
   * @var \Drupal\Core\Lock\LockBackendInterface $lockBackend
   */
  protected $lockBackend;

  /**
   * The current user.
   *
   * @var \Drupal\Core\Session\AccountProxyInterface
   */
  protected $currentUser;

  /**
   * The request stack.
   *
   * @var \Symfony\Component\HttpFoundation\RequestStack
   */
  protected $requestStack;

  /**
   * The time to live for items in seconds.
   *
   * @var int
   */
  protected $expire;

  /**
   * Constructs a Drupal\user\PrivateTempStoreFactory object.
   *
   * @param \Drupal\Core\Database\Connection $connection
   *   The connection object used for this data.
   * @param \Drupal\Core\Lock\LockBackendInterface $lockBackend
   *   The lock object used for this data.
   * @param int $expire
   *   The time to live for items, in seconds.
   */
  function __construct(KeyValueExpirableFactoryInterface $storage_factory, LockBackendInterface $lockBackend, AccountProxyInterface $current_user, RequestStack $request_stack, $expire = 604800) {
    $this->storageFactory = $storage_factory;
    $this->lockBackend = $lockBackend;
    $this->currentUser = $current_user;
    $this->requestStack = $request_stack;
    $this->expire = $expire;
  }

  /**
   * Creates a PrivateTempStore.
   *
   * @param string $collection
   *   The collection name to use for this key/value store. This is typically
   *   a shared namespace or module name, e.g. 'views', 'entity', etc.
   *
   * @return \Drupal\user\PrivateTempStore
   *   An instance of the key/value store.
   */
  function get($collection) {

    // Store the data for this collection in the database.
    $storage = $this->storageFactory
      ->get("user.private_tempstore.{$collection}");
    return new PrivateTempStore($storage, $this->lockBackend, $this->currentUser, $this->requestStack, $this->expire);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PrivateTempStoreFactory::$currentUser protected property The current user.
PrivateTempStoreFactory::$expire protected property The time to live for items in seconds.
PrivateTempStoreFactory::$lockBackend protected property The lock object used for this data.
PrivateTempStoreFactory::$requestStack protected property The request stack.
PrivateTempStoreFactory::$storageFactory protected property The storage factory creating the backend to store the data.
PrivateTempStoreFactory::get function Creates a PrivateTempStore.
PrivateTempStoreFactory::__construct function Constructs a Drupal\user\PrivateTempStoreFactory object.