Same name in this branch
  1. 8.6.x core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php \Drupal\Core\TempStore\PrivateTempStoreFactory
  2. 8.6.x core/modules/user/src/PrivateTempStoreFactory.php \Drupal\user\PrivateTempStoreFactory
Same name and namespace in other branches
  1. 9.0.x core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php \Drupal\Core\TempStore\PrivateTempStoreFactory
  2. 9.1.x core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php \Drupal\Core\TempStore\PrivateTempStoreFactory
  3. 9.2.x core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php \Drupal\Core\TempStore\PrivateTempStoreFactory
  4. 8.9.x core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php \Drupal\Core\TempStore\PrivateTempStoreFactory
  5. 8.5.x core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php \Drupal\Core\TempStore\PrivateTempStoreFactory
  6. 8.7.x core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php \Drupal\Core\TempStore\PrivateTempStoreFactory
  7. 8.8.x core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php \Drupal\Core\TempStore\PrivateTempStoreFactory

Creates a PrivateTempStore object for a given collection.

Hierarchy

Expanded class hierarchy of PrivateTempStoreFactory

21 files declare their use of PrivateTempStoreFactory
CancelUser.php in core/modules/user/src/Plugin/Action/CancelUser.php
CommentAdminOverview.php in core/modules/comment/src/Form/CommentAdminOverview.php
CredentialForm.php in core/modules/migrate_drupal_ui/src/Form/CredentialForm.php
DeleteAction.php in core/lib/Drupal/Core/Action/Plugin/Action/DeleteAction.php
DeleteComment.php in core/modules/comment/src/Plugin/Action/DeleteComment.php

... See full list

1 string reference to 'PrivateTempStoreFactory'
core.services.yml in core/core.services.yml
core/core.services.yml

File

core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php, line 13

Namespace

Drupal\Core\TempStore
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
   */
  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\Core\TempStore\PrivateTempStoreFactory object.
   *
   * @param \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface $storage_factory
   *   The key/value store factory.
   * @param \Drupal\Core\Lock\LockBackendInterface $lock_backend
   *   The lock object used for this data.
   * @param \Drupal\Core\Session\AccountProxyInterface $current_user
   *   The current account.
   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
   *   The request stack.
   * @param int $expire
   *   The time to live for items, in seconds.
   */
  public function __construct(KeyValueExpirableFactoryInterface $storage_factory, LockBackendInterface $lock_backend, AccountProxyInterface $current_user, RequestStack $request_stack, $expire = 604800) {
    $this->storageFactory = $storage_factory;
    $this->lockBackend = $lock_backend;
    $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\Core\TempStore\PrivateTempStore
   *   An instance of the key/value store.
   */
  public function get($collection) {

    // Store the data for this collection in the database.
    $storage = $this->storageFactory
      ->get("tempstore.private.{$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 public function Creates a PrivateTempStore. 1
PrivateTempStoreFactory::__construct public function Constructs a Drupal\Core\TempStore\PrivateTempStoreFactory object.