public function AccessTokenManager::getActiveAccessToken in Access unpublished 8
Obtains an active access token for a given entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity.
Return value
\Drupal\access_unpublished\AccessTokenInterface|null An Access Token entity.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- src/
AccessTokenManager.php, line 141
Class
- AccessTokenManager
- Service to work with access tokens.
Namespace
Drupal\access_unpublishedCode
public function getActiveAccessToken(EntityInterface $entity) {
if ($tokens = $this
->getAccessTokensByEntity($entity, 'active')) {
return current($tokens);
}
return NULL;
}