function SharedTempStore::delete

Same name in other branches
  1. 9 core/lib/Drupal/Core/TempStore/SharedTempStore.php \Drupal\Core\TempStore\SharedTempStore::delete()
  2. 8.9.x core/lib/Drupal/Core/TempStore/SharedTempStore.php \Drupal\Core\TempStore\SharedTempStore::delete()
  3. 11.x core/lib/Drupal/Core/TempStore/SharedTempStore.php \Drupal\Core\TempStore\SharedTempStore::delete()

Deletes data from the store for a given key and releases the lock on it.

Parameters

string $key: The key of the data to delete.

Throws

\Drupal\Core\TempStore\TempStoreException Thrown when a lock for the backend storage could not be acquired.

1 call to SharedTempStore::delete()
SharedTempStore::deleteIfOwner in core/lib/Drupal/Core/TempStore/SharedTempStore.php
Deletes data from the store for a given key and releases the lock on it.

File

core/lib/Drupal/Core/TempStore/SharedTempStore.php, line 258

Class

SharedTempStore
Stores and retrieves temporary data for a given owner.

Namespace

Drupal\Core\TempStore

Code

public function delete($key) {
    if (!$this->lockBackend
        ->acquire($key)) {
        $this->lockBackend
            ->wait($key);
        if (!$this->lockBackend
            ->acquire($key)) {
            throw new TempStoreException("Couldn't acquire lock to delete item '{$key}' from {$this->storage->getCollectionName()} temporary storage.");
        }
    }
    $this->storage
        ->delete($key);
    $this->lockBackend
        ->release($key);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.