You are here

public function SharedTempStore::deleteIfOwner in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/SharedTempStore.php \Drupal\user\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.

File

core/modules/user/src/SharedTempStore.php, line 260
Contains \Drupal\user\SharedTempStore.

Class

SharedTempStore
Stores and retrieves temporary data for a given owner.

Namespace

Drupal\user

Code

public function deleteIfOwner($key) {
  if (!($object = $this->storage
    ->get($key))) {
    return TRUE;
  }
  elseif ($object->owner == $this->owner) {
    $this
      ->delete($key);
    return TRUE;
  }
  return FALSE;
}