class TokenEntityNormalizer 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
- 8.3 src/Normalizer/TokenEntityNormalizer.php \Drupal\simple_oauth\Normalizer\TokenEntityNormalizer
- 5.x src/Normalizer/TokenEntityNormalizer.php \Drupal\simple_oauth\Normalizer\TokenEntityNormalizer
Hierarchy
- class \Drupal\serialization\Normalizer\NormalizerBase implements \Symfony\Component\Serializer\SerializerAwareInterface, CacheableNormalizerInterface uses \Symfony\Component\Serializer\SerializerAwareTrait
- class \Drupal\simple_oauth\Normalizer\TokenEntityNormalizer implements TokenEntityNormalizerInterface
Expanded class hierarchy of TokenEntityNormalizer
1 string reference to 'TokenEntityNormalizer'
1 service uses TokenEntityNormalizer
File
- src/
Normalizer/ TokenEntityNormalizer.php, line 9
Namespace
Drupal\simple_oauth\NormalizerView source
class TokenEntityNormalizer extends NormalizerBase implements TokenEntityNormalizerInterface {
/**
* The interface or class that this Normalizer supports.
*
* @var string|array
*/
protected $supportedInterfaceOrClass = '\\League\\OAuth2\\Server\\Entities\\TokenInterface';
/**
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
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,
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableNormalizerInterface:: |
constant | Name of key for bubbling cacheability metadata via serialization context. | ||
NormalizerBase:: |
protected | property | List of formats which supports (de-)normalization. | 3 |
NormalizerBase:: |
protected | function | Adds cacheability if applicable. | |
NormalizerBase:: |
protected | function | Checks if the provided format is supported by this normalizer. | 2 |
NormalizerBase:: |
public | function | Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() | 1 |
NormalizerBase:: |
public | function | Checks whether the given class is supported for normalization by this normalizer. | 1 |
TokenEntityNormalizer:: |
protected | property | ||
TokenEntityNormalizer:: |
protected | property |
The interface or class that this Normalizer supports. Overrides NormalizerBase:: |
|
TokenEntityNormalizer:: |
public | function | Normalizes an object into a set of arrays/scalars. | |
TokenEntityNormalizer:: |
public | function |