class SharedTempStoreFactory in Drupal 8
Same name in this branch
- 8 core/modules/user/src/SharedTempStoreFactory.php \Drupal\user\SharedTempStoreFactory
- 8 core/lib/Drupal/Core/TempStore/SharedTempStoreFactory.php \Drupal\Core\TempStore\SharedTempStoreFactory
Creates a shared temporary storage for a collection.
Hierarchy
- class \Drupal\Core\TempStore\SharedTempStoreFactory
- class \Drupal\user\SharedTempStoreFactory
Expanded class hierarchy of SharedTempStoreFactory
Deprecated
in drupal:8.5.0 and is removed from drupal:9.0.0. Use \Drupal\Core\TempStore\SharedTempStoreFactory instead.
See also
\Drupal\Core\TempStore\SharedTempStoreFactory
https://www.drupal.org/node/2935639
1 file declares its use of SharedTempStoreFactory
- TempStoreDatabaseTest.php in core/
modules/ user/ tests/ src/ Kernel/ TempStoreDatabaseTest.php
1 string reference to 'SharedTempStoreFactory'
- user.services.yml in core/
modules/ user/ user.services.yml - core/modules/user/user.services.yml
1 service uses SharedTempStoreFactory
- user.shared_tempstore in core/
modules/ user/ user.services.yml - Drupal\user\SharedTempStoreFactory
File
- core/
modules/ user/ src/ SharedTempStoreFactory.php, line 18
Namespace
Drupal\userView source
class SharedTempStoreFactory extends CoreSharedTempStoreFactory {
/**
* Creates a SharedTempStore for the current user or anonymous session.
*
* @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.
* @param mixed $owner
* (optional) The owner of this SharedTempStore. By default, the
* SharedTempStore is owned by the currently authenticated user, or by the
* active anonymous session if no user is logged in.
*
* @return \Drupal\user\SharedTempStore
* An instance of the key/value store.
*/
public function get($collection, $owner = NULL) {
// Use the currently authenticated user ID or the active user ID unless
// the owner is overridden.
if (!isset($owner)) {
$owner = \Drupal::currentUser()
->id() ?: session_id();
}
// Store the data for this collection in the database.
$storage = $this->storageFactory
->get("user.shared_tempstore.{$collection}");
return new SharedTempStore($storage, $this->lockBackend, $owner, $this->requestStack, $this->expire);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SharedTempStoreFactory:: |
protected | property | The time to live for items in seconds. | |
SharedTempStoreFactory:: |
protected | property | The lock object used for this data. | |
SharedTempStoreFactory:: |
protected | property | The request stack. | |
SharedTempStoreFactory:: |
protected | property | The storage factory creating the backend to store the data. | |
SharedTempStoreFactory:: |
public | function |
Creates a SharedTempStore for the current user or anonymous session. Overrides SharedTempStoreFactory:: |
|
SharedTempStoreFactory:: |
public | function | Constructs a Drupal\Core\TempStore\SharedTempStoreFactory object. |