function PrivateTempStore::getMetadata
Same name in other branches
- 9 core/lib/Drupal/Core/TempStore/PrivateTempStore.php \Drupal\Core\TempStore\PrivateTempStore::getMetadata()
- 8.9.x core/lib/Drupal/Core/TempStore/PrivateTempStore.php \Drupal\Core\TempStore\PrivateTempStore::getMetadata()
- 10 core/lib/Drupal/Core/TempStore/PrivateTempStore.php \Drupal\Core\TempStore\PrivateTempStore::getMetadata()
Returns the metadata associated with a particular key/value pair.
Parameters
string $key: The key of the data to store.
Return value
\Drupal\Core\TempStore\Lock|null An object with the owner and updated time if the key has a value, or NULL otherwise.
File
-
core/
lib/ Drupal/ Core/ TempStore/ PrivateTempStore.php, line 157
Class
- PrivateTempStore
- Stores and retrieves temporary data for a given owner.
Namespace
Drupal\Core\TempStoreCode
public function getMetadata($key) {
$key = $this->createKey($key);
// Fetch the key/value pair and its metadata.
$object = $this->storage
->get($key);
if ($object) {
// Don't keep the data itself in memory.
unset($object->data);
return new Lock($object->owner, $object->updated);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.