function simple_oauth_cron in Simple OAuth (OAuth2) & OpenID Connect 8.4
Same name and namespace in other branches
- 8 simple_oauth.module \simple_oauth_cron()
- 8.2 simple_oauth.module \simple_oauth_cron()
- 8.3 simple_oauth.module \simple_oauth_cron()
- 5.x simple_oauth.module \simple_oauth_cron()
Implements hook_cron().
File
- ./
simple_oauth.module, line 23 - Contains simple_oauth.module.
Code
function simple_oauth_cron() {
/** @var \Drupal\simple_oauth\ExpiredCollector $collector */
$collector = \Drupal::service('simple_oauth.expired_collector');
$config = \Drupal::config('simple_oauth.settings');
$logger = \Drupal::logger('simple_oauth');
$token_cron_batch_size = $config
->get('token_cron_batch_size');
// Deleting one batch of expired tokens.
if (!empty($expired_tokens = $collector
->collect($token_cron_batch_size))) {
$collector
->deleteMultipleTokens($expired_tokens);
$logger
->notice('Deleted @limit expired tokens in cron.', [
'@limit' => $token_cron_batch_size,
]);
}
}