You are here

public function Oauth2ClientServiceBase::getClient in OAuth2 Client 8.2

Same name and namespace in other branches
  1. 8.3 src/Service/Oauth2ClientServiceBase.php \Drupal\oauth2_client\Service\Oauth2ClientServiceBase::getClient()

Retrieve an OAuth2 Client Plugin.

Parameters

string $clientId: The plugin ID of the client to be retrieved.

Return value

\Drupal\oauth2_client\Plugin\Oauth2Client\Oauth2ClientPluginInterface The OAuth2 Client plugin.

Overrides Oauth2ClientServiceInterface::getClient

4 calls to Oauth2ClientServiceBase::getClient()
Oauth2ClientGrantServiceBase::getProvider in src/Service/Grant/Oauth2ClientGrantServiceBase.php
Creates a new provider object.
Oauth2ClientService::getAccessToken in src/Service/Oauth2ClientService.php
Oauth2ClientService::getProvider in src/Service/Oauth2ClientService.php
ResourceOwnersCredentialsGrantService::getAccessToken in src/Service/Grant/ResourceOwnersCredentialsGrantService.php
Get an OAuth2 access token.

File

src/Service/Oauth2ClientServiceBase.php, line 15

Class

Oauth2ClientServiceBase
Base class for OAuth2 Client services.

Namespace

Drupal\oauth2_client\Service

Code

public function getClient($clientId) {
  $clients =& drupal_static(__CLASS__ . '::' . __FUNCTION__, []);
  if (!isset($clients[$clientId])) {
    $definition = $this->oauth2ClientPluginManager
      ->getDefinition($clientId);
    if (!$definition || !isset($definition['id'])) {
      throw new InvalidOauth2ClientException($clientId);
    }
    $clients[$clientId] = $this->oauth2ClientPluginManager
      ->createInstance($definition['id']);
  }
  return $clients[$clientId];
}