PrivateTempStoreFactory.php
Same filename and directory in other branches
- 8.9.x core/modules/user/src/PrivateTempStoreFactory.php
- 11.x core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php
- 10 core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php
- 9 core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php
- 8.9.x core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php
Namespace
Drupal\Core\TempStoreFile
-
core/
lib/ Drupal/ Core/ TempStore/ PrivateTempStoreFactory.php
View source
<?php
namespace Drupal\Core\TempStore;
use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface;
use Drupal\Core\Lock\LockBackendInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Creates a PrivateTempStore object for a given collection.
*/
class PrivateTempStoreFactory {
/**
* Constructs a Drupal\Core\TempStore\PrivateTempStoreFactory object.
*
* @param \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface $storageFactory
* The key/value store factory.
* @param \Drupal\Core\Lock\LockBackendInterface $lockBackend
* The lock object used for this data.
* @param \Drupal\Core\Session\AccountProxyInterface $currentUser
* The current account.
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
* The request stack.
* @param int $expire
* The time to live for items, in seconds.
*/
public function __construct(protected KeyValueExpirableFactoryInterface $storageFactory, protected LockBackendInterface $lockBackend, protected AccountProxyInterface $currentUser, protected RequestStack $requestStack, protected $expire = 604800) {
}
/**
* 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);
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| PrivateTempStoreFactory | Creates a PrivateTempStore object for a given collection. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.