function SharedTempStore::deleteIfOwner
Same name in other branches
- 9 core/lib/Drupal/Core/TempStore/SharedTempStore.php \Drupal\Core\TempStore\SharedTempStore::deleteIfOwner()
- 10 core/lib/Drupal/Core/TempStore/SharedTempStore.php \Drupal\Core\TempStore\SharedTempStore::deleteIfOwner()
- 11.x core/lib/Drupal/Core/TempStore/SharedTempStore.php \Drupal\Core\TempStore\SharedTempStore::deleteIfOwner()
Deletes data from the store for a given key and releases the lock on it.
Only delete the given key if it is owned by $this->owner.
Parameters
string $key: The key of the data to delete.
Return value
bool TRUE if the object was deleted or does not exist, FALSE if it exists but is not owned by $this->owner.
Throws
\Drupal\Core\TempStore\TempStoreException Thrown when a lock for the backend storage could not be acquired.
File
-
core/
lib/ Drupal/ Core/ TempStore/ SharedTempStore.php, line 270
Class
- SharedTempStore
- Stores and retrieves temporary data for a given owner.
Namespace
Drupal\Core\TempStoreCode
public function deleteIfOwner($key) {
if (!($object = $this->storage
->get($key))) {
return TRUE;
}
elseif ($object->owner == $this->owner) {
$this->delete($key);
return TRUE;
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.