You are here

function lti_tool_provider_cron in LTI Tool Provider 2.x

Same name and namespace in other branches
  1. 8 lti_tool_provider.module \lti_tool_provider_cron()

Implements hook_cron().

File

./lti_tool_provider.module, line 39
LTI Tool Provider hook implementations and support functions.

Code

function lti_tool_provider_cron() {
  $expires = time() - LTI_TOOL_PROVIDER_NONCE_EXPIRY;
  try {
    $nonceStorage = Drupal::entityTypeManager()
      ->getStorage('lti_tool_provider_nonce');
    $ids = $nonceStorage
      ->getQuery()
      ->condition('timestamp', $expires, '<')
      ->execute();
    $entities = $nonceStorage
      ->loadMultiple($ids);
    $nonceStorage
      ->delete($entities);
  } catch (Exception $e) {
    Drupal::logger('lti_tool_provider')
      ->error($e
      ->getMessage());
  }
}