public function UsersJwtKeyRepository::getKey in JSON Web Token Authentication (JWT) 8
Get a user key by key ID.
Parameters
string $id: The unique ID of the key.
Return value
\Drupal\users_jwt\UsersKey|null Key data object, or NULL if no matching key was found.
Overrides UsersJwtKeyRepositoryInterface::getKey
2 calls to UsersJwtKeyRepository::getKey()
- UsersJwtKeyRepository::offsetExists in modules/
users_jwt/ src/ UsersJwtKeyRepository.php - UsersJwtKeyRepository::offsetGet in modules/
users_jwt/ src/ UsersJwtKeyRepository.php - Extends \ArrayAccess::offsetGet().
File
- modules/
users_jwt/ src/ UsersJwtKeyRepository.php, line 63
Class
- UsersJwtKeyRepository
- Class UsersJwtKeyRepository
Namespace
Drupal\users_jwtCode
public function getKey($id) : ?UsersKey {
$cached = $this->keyCache
->get($id);
if ($cached) {
$key = $cached->data;
}
else {
$keys = $this->userData
->get('users_jwt', NULL, $id);
// The key ID needs to be unique.
if (empty($keys) || count($keys) > 1) {
$key = NULL;
}
else {
$key = end($keys);
}
$this->keyCache
->set($id, $key);
}
return $key;
}