protected function AccessTokenManager::buildAccessTokenQuery in Access unpublished 8
Builds a generic query to obtain some access tokens.
Parameters
string $status: Status of the token. Possible values are 'active' and 'expired'. No parameter will return all tokens.
Return value
\Drupal\Core\Entity\Query\QueryInterface An access token query.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to AccessTokenManager::buildAccessTokenQuery()
- AccessTokenManager::getAccessTokensByEntity in src/
AccessTokenManager.php - Obtains access tokens for a given entity.
File
- src/
AccessTokenManager.php, line 110
Class
- AccessTokenManager
- Service to work with access tokens.
Namespace
Drupal\access_unpublishedCode
protected function buildAccessTokenQuery($status = NULL) {
$query = $this->entityTypeManager
->getStorage('access_token')
->getQuery();
if ($status == 'active') {
$group = $query
->orConditionGroup()
->condition('expire', time(), '>=')
->condition('expire', '-1');
$query
->condition($group);
}
elseif ($status == 'expired') {
$group = $query
->andConditionGroup()
->condition('expire', time(), '<')
->condition('expire', '-1', '!=');
$query
->condition($group);
}
$query
->sort('expire', 'ASC');
return $query;
}