You are here

public function UserClaimsNormalizer::normalize in Simple OAuth (OAuth2) & OpenID Connect 5.x

File

src/Normalizer/UserClaimsNormalizer.php, line 65

Class

UserClaimsNormalizer
Normalizes a user entity to extract the claims.

Namespace

Drupal\simple_oauth\Normalizer

Code

public function normalize($user_entity, $format = NULL, array $context = []) {
  assert($user_entity instanceof UserEntityWithClaims);
  $identifier = $user_entity
    ->getIdentifier();

  // Check if the account is in $context. If not, load it from the database.
  $account = $context[$identifier] instanceof AccountInterface ? $context[$identifier] : $this->userStorage
    ->load($identifier);
  assert($account instanceof AccountInterface);
  return $this
    ->getClaimsFromAccount($account);
}