You are here

public function ClientRepository::getClientEntity in Simple OAuth (OAuth2) & OpenID Connect 5.x

Same name and namespace in other branches
  1. 8.4 src/Repositories/ClientRepository.php \Drupal\simple_oauth\Repositories\ClientRepository::getClientEntity()
  2. 8.2 src/Repositories/ClientRepository.php \Drupal\simple_oauth\Repositories\ClientRepository::getClientEntity()
  3. 8.3 src/Repositories/ClientRepository.php \Drupal\simple_oauth\Repositories\ClientRepository::getClientEntity()

File

src/Repositories/ClientRepository.php, line 33

Class

ClientRepository

Namespace

Drupal\simple_oauth\Repositories

Code

public function getClientEntity($client_identifier) {
  $client_drupal_entities = $this->entityTypeManager
    ->getStorage('consumer')
    ->loadByProperties([
    'uuid' => $client_identifier,
  ]);

  // Check if the client is registered.
  if (empty($client_drupal_entities)) {
    return NULL;
  }

  /** @var \Drupal\consumers\Entity\Consumer $client_drupal_entity */
  $client_drupal_entity = reset($client_drupal_entities);
  return new ClientEntity($client_drupal_entity);
}