public function ExpiredCollector::collect in Simple OAuth (OAuth2) & OpenID Connect 8.4
Same name and namespace in other branches
- 8.2 src/ExpiredCollector.php \Drupal\simple_oauth\ExpiredCollector::collect()
- 8.3 src/ExpiredCollector.php \Drupal\simple_oauth\ExpiredCollector::collect()
- 5.x src/ExpiredCollector.php \Drupal\simple_oauth\ExpiredCollector::collect()
Collect all expired token ids.
Parameters
int $limit: Number of tokens to fetch.
Return value
\Drupal\simple_oauth\Entity\Oauth2TokenInterface[] The expired tokens.
File
- src/
ExpiredCollector.php, line 62
Class
- ExpiredCollector
- Service in charge of deleting or expiring tokens that cannot be used anymore.
Namespace
Drupal\simple_oauthCode
public function collect($limit = 0) {
$query = $this->tokenStorage
->getQuery();
$query
->condition('expire', $this->dateTime
->getRequestTime(), '<');
// If limit available.
if (!empty($limit)) {
$query
->range(0, $limit);
}
if (!($results = $query
->execute())) {
return [];
}
return array_values($this->tokenStorage
->loadMultiple(array_values($results)));
}