public function AccessTokenManager::getAccessTokensByEntity in Access unpublished 8
Obtains access tokens for a given entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity.
string $status: Status of the token. Possible values are 'active' and 'expired'. No parameter will return all tokens.
Return value
\Drupal\access_unpublished\AccessTokenInterface[] The access tokens.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to AccessTokenManager::getAccessTokensByEntity()
- AccessTokenManager::getActiveAccessToken in src/
AccessTokenManager.php - Obtains an active access token for a given entity.
File
- src/
AccessTokenManager.php, line 68
Class
- AccessTokenManager
- Service to work with access tokens.
Namespace
Drupal\access_unpublishedCode
public function getAccessTokensByEntity(EntityInterface $entity, $status = NULL) {
if (!AccessUnpublished::applicableEntityType($entity
->getEntityType())) {
return [];
}
$query = $this
->buildAccessTokenQuery($status);
$tokens = $query
->condition('entity_type', $entity
->getEntityType()
->id())
->condition('entity_id', $entity
->id())
->execute();
return $this->entityTypeManager
->getStorage('access_token')
->loadMultiple($tokens);
}