From cd68103267ceb84dcffbbf7277a40319f86b6495 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sun, 17 Jan 2016 14:03:41 +0000 Subject: [PATCH] New server constructor --- src/Server.php | 53 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/src/Server.php b/src/Server.php index b9d67e24..dfb61303 100644 --- a/src/Server.php +++ b/src/Server.php @@ -7,6 +7,9 @@ use League\Event\EmitterAwareInterface; use League\Event\EmitterAwareTrait; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Grant\GrantTypeInterface; +use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; +use League\OAuth2\Server\Repositories\ClientRepositoryInterface; +use League\OAuth2\Server\Repositories\ScopeRepositoryInterface; use League\OAuth2\Server\ResponseTypes\BearerTokenResponse; use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface; use Psr\Http\Message\ResponseInterface; @@ -46,27 +49,47 @@ class Server implements EmitterAwareInterface /** * @var string */ + private $defaultPublicKeyPath; + + /** + * @var \League\OAuth2\Server\Repositories\ClientRepositoryInterface + */ + private $clientRepository; + + /** + * @var \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface + */ + private $accessTokenRepository; + + /** + * @var \League\OAuth2\Server\Repositories\ScopeRepositoryInterface + */ + private $scopeRepository; /** * New server instance * - * @param string $defaultPrivateKeyPath - * @param DateInterval $defaultAccessTokenTTL + * @param \League\OAuth2\Server\Repositories\ClientRepositoryInterface $clientRepository + * @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository + * @param \League\OAuth2\Server\Repositories\ScopeRepositoryInterface $scopeRepository + * @param string $defaultPrivateKeyPath + * @param string $defaultPublicKeyPath + * @param null|\League\OAuth2\Server\ResponseTypes\ResponseTypeInterface $responseType */ - public function __construct($defaultPrivateKeyPath, \DateInterval $defaultAccessTokenTTL = null) - { + public function __construct( + ClientRepositoryInterface $clientRepository, + AccessTokenRepositoryInterface $accessTokenRepository, + ScopeRepositoryInterface $scopeRepository, + $defaultPrivateKeyPath, + $defaultPublicKeyPath, + ResponseTypeInterface $responseType = null + ) { $this->defaultPrivateKeyPath = $defaultPrivateKeyPath; - $this->defaultAccessTokenTTL = $defaultAccessTokenTTL; - } - - /** - * Set the default token type that grants will return - * - * @param ResponseTypeInterface $defaultTokenType - */ - public function setDefaultResponseType(ResponseTypeInterface $defaultTokenType) - { - $this->defaultResponseType = $defaultTokenType; + $this->defaultPublicKeyPath = $defaultPublicKeyPath; + $this->clientRepository = $clientRepository; + $this->accessTokenRepository = $accessTokenRepository; + $this->scopeRepository = $scopeRepository; + $this->defaultResponseType = $responseType; } /**