Oauth2ClientPluginBase.php in OAuth2 Client 8.2
File
src/Plugin/Oauth2Client/Oauth2ClientPluginBase.php
View source
<?php
namespace Drupal\oauth2_client\Plugin\Oauth2Client;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\oauth2_client\Exception\Oauth2ClientPluginMissingKeyException;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class Oauth2ClientPluginBase extends PluginBase implements Oauth2ClientPluginInterface {
protected $configFactory;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $configFactory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configFactory = $configFactory;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory'));
}
public function getName() {
$this
->checkKeyDefined('name');
return $this->pluginDefinition['name'];
}
public function getId() {
$this
->checkKeyDefined('id');
return $this->pluginDefinition['id'];
}
public function getClientId() {
$this
->checkKeyDefined('client_id');
return $this->pluginDefinition['client_id'];
}
public function getClientSecret() {
$this
->checkKeyDefined('client_secret');
return $this->pluginDefinition['client_secret'];
}
public function getGrantType() {
$this
->checkKeyDefined('grant_type');
return $this->pluginDefinition['grant_type'];
}
public function getRedirectUri() {
$this
->checkKeyDefined('redirect_uri');
return $this->pluginDefinition['redirect_uri'];
}
public function getAuthorizationUri() {
$this
->checkKeyDefined('authorization_uri');
return $this->pluginDefinition['authorization_uri'];
}
public function getTokenUri() {
$this
->checkKeyDefined('token_uri');
return $this->pluginDefinition['token_uri'];
}
public function getResourceUri() {
$this
->checkKeyDefined('resource_owner_uri');
return $this->pluginDefinition['resource_owner_uri'];
}
public function getScopes() {
if (!isset($this->pluginDefinition['scopes'])) {
return [];
}
return $this->pluginDefinition['scopes'] ?: [];
}
public function getScopeSeparator() {
if (!isset($this->pluginDefinition['scope_separator'])) {
return ',';
}
return $this->pluginDefinition['scope_separator'];
}
public function getUsername() {
$this
->checkKeyDefined('username');
return $this->pluginDefinition['username'];
}
public function getPassword() {
$this
->checkKeyDefined('password');
return $this->pluginDefinition['password'];
}
private function checkKeyDefined($key) {
if (!isset($this->pluginDefinition[$key])) {
throw new Oauth2ClientPluginMissingKeyException($key);
}
}
}