You are here

abstract class Oauth2ClientPluginBase in OAuth2 Client 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/Oauth2Client/Oauth2ClientPluginBase.php \Drupal\oauth2_client\Plugin\Oauth2Client\Oauth2ClientPluginBase

Base class for Oauth2Client plugins.

Hierarchy

Expanded class hierarchy of Oauth2ClientPluginBase

File

src/Plugin/Oauth2Client/Oauth2ClientPluginBase.php, line 13

Namespace

Drupal\oauth2_client\Plugin\Oauth2Client
View source
abstract class Oauth2ClientPluginBase extends PluginBase implements Oauth2ClientPluginInterface {

  /**
   * The configuration factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs a Oauth2ClientPluginBase object.
   *
   * @param array $configuration
   *   The plugin configuration.
   * @param string $plugin_id
   *   The plugin ID.
   * @param mixed $plugin_definition
   *   The plugin definitions.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
   *   The configuration factory service.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $configFactory) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->configFactory = $configFactory;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('config.factory'));
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    $this
      ->checkKeyDefined('name');
    return $this->pluginDefinition['name'];
  }

  /**
   * {@inheritdoc}
   */
  public function getId() {
    $this
      ->checkKeyDefined('id');
    return $this->pluginDefinition['id'];
  }

  /**
   * {@inheritdoc}
   */
  public function getClientId() {
    $this
      ->checkKeyDefined('client_id');
    return $this->pluginDefinition['client_id'];
  }

  /**
   * {@inheritdoc}
   */
  public function getClientSecret() {
    $this
      ->checkKeyDefined('client_secret');
    return $this->pluginDefinition['client_secret'];
  }

  /**
   * {@inheritdoc}
   */
  public function getGrantType() {
    $this
      ->checkKeyDefined('grant_type');
    return $this->pluginDefinition['grant_type'];
  }

  /**
   * {@inheritdoc}
   */
  public function getRedirectUri() {
    $this
      ->checkKeyDefined('redirect_uri');
    return $this->pluginDefinition['redirect_uri'];
  }

  /**
   * {@inheritdoc}
   */
  public function getAuthorizationUri() {
    $this
      ->checkKeyDefined('authorization_uri');
    return $this->pluginDefinition['authorization_uri'];
  }

  /**
   * {@inheritdoc}
   */
  public function getTokenUri() {
    $this
      ->checkKeyDefined('token_uri');
    return $this->pluginDefinition['token_uri'];
  }

  /**
   * {@inheritdoc}
   */
  public function getResourceUri() {
    $this
      ->checkKeyDefined('resource_owner_uri');
    return $this->pluginDefinition['resource_owner_uri'];
  }

  /**
   * {@inheritdoc}
   */
  public function getScopes() {
    if (!isset($this->pluginDefinition['scopes'])) {
      return [];
    }
    return $this->pluginDefinition['scopes'] ?: [];
  }

  /**
   * {@inheritdoc}
   */
  public function getScopeSeparator() {
    if (!isset($this->pluginDefinition['scope_separator'])) {
      return ',';
    }
    return $this->pluginDefinition['scope_separator'];
  }

  /**
   * {@inheritdoc}
   */
  public function getUsername() {
    $this
      ->checkKeyDefined('username');
    return $this->pluginDefinition['username'];
  }

  /**
   * {@inheritdoc}
   */
  public function getPassword() {
    $this
      ->checkKeyDefined('password');
    return $this->pluginDefinition['password'];
  }

  /**
   * Check that a key is defined when requested. Throw an exception if not.
   *
   * @param string $key
   *   The key to check.
   *
   * @throws \Drupal\oauth2_client\Exception\Oauth2ClientPluginMissingKeyException
   *   Thrown if the key being checked is not defined.
   */
  private function checkKeyDefined($key) {
    if (!isset($this->pluginDefinition[$key])) {
      throw new Oauth2ClientPluginMissingKeyException($key);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
Oauth2ClientPluginBase::$configFactory protected property The configuration factory.
Oauth2ClientPluginBase::checkKeyDefined private function Check that a key is defined when requested. Throw an exception if not.
Oauth2ClientPluginBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
Oauth2ClientPluginBase::getAuthorizationUri public function Retrieves the authorization_uri of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getAuthorizationUri
Oauth2ClientPluginBase::getClientId public function Retrieves the client_id of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getClientId
Oauth2ClientPluginBase::getClientSecret public function Retrieves the client_secret of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getClientSecret
Oauth2ClientPluginBase::getGrantType public function Retrieves the grant type of the plugin. Overrides Oauth2ClientPluginInterface::getGrantType
Oauth2ClientPluginBase::getId public function Retrieves the id of the OAuth2 Client plugin. Overrides Oauth2ClientPluginInterface::getId
Oauth2ClientPluginBase::getName public function Retrieves the human-readable name of the Oauth2 Client plugin. Overrides Oauth2ClientPluginInterface::getName
Oauth2ClientPluginBase::getPassword public function Retrieves the password for the account to authenticate with. Overrides Oauth2ClientPluginInterface::getPassword
Oauth2ClientPluginBase::getRedirectUri public function Retrieves the redirect_uri of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getRedirectUri
Oauth2ClientPluginBase::getResourceUri public function Retrieves the resource_uri of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getResourceUri
Oauth2ClientPluginBase::getScopes public function Get the set of scopes for the provider to use by default. Overrides Oauth2ClientPluginInterface::getScopes
Oauth2ClientPluginBase::getScopeSeparator public function Get the separator used to join the scopes in the OAuth2 query string. Overrides Oauth2ClientPluginInterface::getScopeSeparator
Oauth2ClientPluginBase::getTokenUri public function Retrieves the token_uri of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getTokenUri
Oauth2ClientPluginBase::getUsername public function Retrieves the username for the account to authenticate with. Overrides Oauth2ClientPluginInterface::getUsername
Oauth2ClientPluginBase::__construct public function Constructs a Oauth2ClientPluginBase object. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.