class SharedTempStoreFactory (View source)

Creates a shared temporary storage for a collection.

Properties

protected KeyValueExpirableFactoryInterface $storageFactory

The storage factory creating the backend to store the data.

protected LockBackendInterface $lockBackend

The lock object used for this data.

protected RequestStack $requestStack

The request stack.

protected int $expire

The time to live for items in seconds.

Methods

__construct(KeyValueExpirableFactoryInterface $storage_factory, LockBackendInterface $lock_backend, RequestStack $request_stack, int $expire = 604800)

Constructs a Drupal\Core\TempStore\SharedTempStoreFactory object.

get(string $collection, mixed $owner = NULL)

Creates a SharedTempStore for the current user or anonymous session.

Details

__construct(KeyValueExpirableFactoryInterface $storage_factory, LockBackendInterface $lock_backend, RequestStack $request_stack, int $expire = 604800)

Constructs a Drupal\Core\TempStore\SharedTempStoreFactory object.

Parameters

KeyValueExpirableFactoryInterface $storage_factory

The key/value store factory.

LockBackendInterface $lock_backend

The lock object used for this data.

RequestStack $request_stack

The request stack.

int $expire

The time to live for items, in seconds.

SharedTempStore get(string $collection, mixed $owner = NULL)

Creates a SharedTempStore for the current user or anonymous session.

Parameters

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.

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 Value

SharedTempStore

An instance of the key/value store.