You are here

public function ExpiredCollector::collect in Simple OAuth (OAuth2) & OpenID Connect 8.2

Same name and namespace in other branches
  1. 8.4 src/ExpiredCollector.php \Drupal\simple_oauth\ExpiredCollector::collect()
  2. 8.3 src/ExpiredCollector.php \Drupal\simple_oauth\ExpiredCollector::collect()
  3. 5.x src/ExpiredCollector.php \Drupal\simple_oauth\ExpiredCollector::collect()

Collect all expired token ids.

Return value

\Drupal\simple_oauth\Entity\Oauth2TokenInterface[] The expired tokens.

File

src/ExpiredCollector.php, line 51

Class

ExpiredCollector
Service in charge of deleting or expiring tokens that cannot be used anymore.

Namespace

Drupal\simple_oauth

Code

public function collect() {
  $query = $this->tokenStorage
    ->getQuery();
  $query
    ->condition('expire', $this->dateTime
    ->getRequestTime(), '<');
  if (!($results = $query
    ->execute())) {
    return [];
  }
  return array_values($this->tokenStorage
    ->loadMultiple(array_values($results)));
}