You are here

abstract class Oauth2ClientServiceBase in OAuth2 Client 8.2

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

Base class for OAuth2 Client services.

Hierarchy

Expanded class hierarchy of Oauth2ClientServiceBase

1 file declares its use of Oauth2ClientServiceBase
Oauth2ClientGrantServiceBase.php in src/Service/Grant/Oauth2ClientGrantServiceBase.php

File

src/Service/Oauth2ClientServiceBase.php, line 10

Namespace

Drupal\oauth2_client\Service
View source
abstract class Oauth2ClientServiceBase implements Oauth2ClientServiceInterface {

  /**
   * {@inheritdoc}
   */
  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];
  }

  /**
   * {@inheritdoc}
   */
  public function retrieveAccessToken($clientId) {
    return $this->state
      ->get('oauth2_client_access_token-' . $clientId);
  }

  /**
   * {@inheritdoc}
   */
  public function clearAccessToken($clientId) {
    return $this->state
      ->delete('oauth2_client_access_token-' . $clientId);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Oauth2ClientServiceBase::clearAccessToken public function Clears the access token for the given client. Overrides Oauth2ClientServiceInterface::clearAccessToken
Oauth2ClientServiceBase::getClient public function Retrieve an OAuth2 Client Plugin. Overrides Oauth2ClientServiceInterface::getClient
Oauth2ClientServiceBase::retrieveAccessToken public function Retrieve an access token from the Drupal state. Overrides Oauth2ClientServiceInterface::retrieveAccessToken