public function SharedTempStore::set in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/src/SharedTempStore.php \Drupal\user\SharedTempStore::set()
Stores a particular key/value pair in this SharedTempStore.
Parameters
string $key: The key of the data to store.
mixed $value: The data to store.
1 call to SharedTempStore::set()
- SharedTempStore::setIfOwner in core/
modules/ user/ src/ SharedTempStore.php - Stores a particular key/value pair in this SharedTempStore.
File
- core/
modules/ user/ src/ SharedTempStore.php, line 194 - Contains \Drupal\user\SharedTempStore.
Class
- SharedTempStore
- Stores and retrieves temporary data for a given owner.
Namespace
Drupal\userCode
public function set($key, $value) {
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.");
}
}
$value = (object) array(
'owner' => $this->owner,
'data' => $value,
'updated' => (int) $this->requestStack
->getMasterRequest()->server
->get('REQUEST_TIME'),
);
$this->storage
->setWithExpire($key, $value, $this->expire);
$this->lockBackend
->release($key);
}