You are here

public function ExpiredCollector::collectForClient in Simple OAuth (OAuth2) & OpenID Connect 5.x

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

Collect all the tokens associated a particular client.

Parameters

\Drupal\consumers\Entity\Consumer $client: The account.

Return value

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

1 call to ExpiredCollector::collectForClient()
ExpiredCollector::collectForAccount in src/ExpiredCollector.php
Collect all the tokens associated with the provided account.

File

src/ExpiredCollector.php, line 124

Class

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

Namespace

Drupal\simple_oauth

Code

public function collectForClient(Consumer $client) {
  $query = $this->tokenStorage
    ->getQuery();
  $query
    ->condition('client', $client
    ->id());
  if (!($entity_ids = $query
    ->execute())) {
    return [];
  }

  /** @var \Drupal\simple_oauth\Entity\Oauth2TokenInterface[] $results */
  $results = $this->tokenStorage
    ->loadMultiple(array_values($entity_ids));
  return array_values($results);
}