public function set($key,
$value) { if ($this->currentUser->
isAnonymous()) { // Ensure that an anonymous user has a session created for them, as
// otherwise subsequent page loads will not be able to retrieve their
// tempstore data. Note this has to be done before the key is created as
// the owner is used in key creation.
$this->
startSession();
$session =
$this->requestStack->
getCurrentRequest()->
getSession();
if (!
$session->
has('core.tempstore.private.owner'
)) { $session->
set('core.tempstore.private.owner', Crypt::
randomBytesBase64());
} } $key =
$this->
createkey($key);
if (!
$this->lockBackend->
acquire($key)) { $this->lockBackend->
wait($key);
if (!
$this->lockBackend->
acquire($key)) { throw new TempStoreException("Couldn't acquire lock to update item '
$key' in '{
$this->storage->
getCollectionName()}' temporary storage."
);
}