You are here

public function Oauth2GrantManager::__construct in Simple OAuth (OAuth2) & OpenID Connect 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/Oauth2GrantManager.php \Drupal\simple_oauth\Plugin\Oauth2GrantManager::__construct()
  2. 8.2 src/Plugin/Oauth2GrantManager.php \Drupal\simple_oauth\Plugin\Oauth2GrantManager::__construct()
  3. 5.x src/Plugin/Oauth2GrantManager.php \Drupal\simple_oauth\Plugin\Oauth2GrantManager::__construct()

Constructor for Oauth2GrantManager objects.

Parameters

\Traversable $namespaces: An object that implements \Traversable which contains the root paths keyed by the corresponding namespace to look for plugin implementations.

\Drupal\Core\Cache\CacheBackendInterface $cache_backend: Cache backend instance to use.

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler to invoke the alter hook with.

\League\OAuth2\Server\Repositories\ClientRepositoryInterface $client_repository: The client repository.

\League\OAuth2\Server\Repositories\ScopeRepositoryInterface $scope_repository: The scope repository.

\League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $access_token_repository: The access token repository.

\League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface $refresh_token_repository: The refresh token repository.

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The config factory.

\League\OAuth2\Server\ResponseTypes\ResponseTypeInterface $response_type: The authorization server response type.

Throws

\Exception

Overrides DefaultPluginManager::__construct

File

src/Plugin/Oauth2GrantManager.php, line 91

Class

Oauth2GrantManager
Provides the OAuth2 Grant plugin manager.

Namespace

Drupal\simple_oauth\Plugin

Code

public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ClientRepositoryInterface $client_repository, ScopeRepositoryInterface $scope_repository, AccessTokenRepositoryInterface $access_token_repository, RefreshTokenRepositoryInterface $refresh_token_repository, ConfigFactoryInterface $config_factory, ResponseTypeInterface $response_type = NULL) {
  parent::__construct('Plugin/Oauth2Grant', $namespaces, $module_handler, 'Drupal\\simple_oauth\\Plugin\\Oauth2GrantInterface', 'Drupal\\simple_oauth\\Annotation\\Oauth2Grant');
  $this
    ->alterInfo('simple_oauth_oauth2_grant_info');
  $this
    ->setCacheBackend($cache_backend, 'simple_oauth_oauth2_grant_plugins');
  $this->clientRepository = $client_repository;
  $this->scopeRepository = $scope_repository;
  $this->accessTokenRepository = $access_token_repository;
  $this->refreshTokenRepository = $refresh_token_repository;
  $this->responseType = $response_type;
  $settings = $config_factory
    ->get('simple_oauth.settings');
  $this
    ->setKeyPaths($settings);
  $this->expiration = new \DateInterval(sprintf('PT%dS', $settings
    ->get('access_token_expiration')));
}