public function TokenEntityNormalizer::normalize in Simple OAuth (OAuth2) & OpenID Connect 8.2
Same name and namespace in other branches
- 8.4 src/Normalizer/TokenEntityNormalizer.php \Drupal\simple_oauth\Normalizer\TokenEntityNormalizer::normalize()
- 8.3 src/Normalizer/TokenEntityNormalizer.php \Drupal\simple_oauth\Normalizer\TokenEntityNormalizer::normalize()
- 5.x src/Normalizer/TokenEntityNormalizer.php \Drupal\simple_oauth\Normalizer\TokenEntityNormalizer::normalize()
File
- src/
Normalizer/ TokenEntityNormalizer.php, line 34
Class
Namespace
Drupal\simple_oauth\NormalizerCode
public function normalize($token_entity, $format = NULL, array $context = array()) {
/** @var \League\OAuth2\Server\Entities\TokenInterface $token_entity */
$scopes = array_map(function ($scope_entity) {
/** @var \League\OAuth2\Server\Entities\ScopeEntityInterface $scope_entity */
return [
'target_id' => $scope_entity
->getIdentifier(),
];
}, $token_entity
->getScopes());
/** @var \Drupal\simple_oauth\Entities\ClientEntityInterface $client */
$client = $token_entity
->getClient();
$client_drupal_entity = $client
->getDrupalEntity();
return [
'auth_user_id' => [
'target_id' => $token_entity
->getUserIdentifier(),
],
'client' => [
'target_id' => $client_drupal_entity
->id(),
],
'scopes' => $scopes,
'value' => $token_entity
->getIdentifier(),
'expire' => $token_entity
->getExpiryDateTime()
->format('U'),
'status' => TRUE,
];
}