-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\authman; | ||
|
||
use Drupal\authman\AuthmanInstance\AuthmanOauthInstanceInterface; | ||
use GuzzleHttp\ClientInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
|
||
/** | ||
* Constructs a Guzzle client proxy for Authman. | ||
*/ | ||
class AuthmanGuzzleClientProxy implements ClientInterface { | ||
|
||
/** | ||
* The authman instance. | ||
* | ||
* @var \Drupal\authman\AuthmanInstance\AuthmanOauthInstanceInterface | ||
*/ | ||
protected $authmanInstance; | ||
|
||
/** | ||
* Constructs a AuthmanGuzzleClientProxy. | ||
* | ||
* @param \Drupal\authman\AuthmanInstance\AuthmanOauthInstanceInterface $authmanInstance | ||
* An authman instance. | ||
*/ | ||
public function __construct(AuthmanOauthInstanceInterface $authmanInstance) { | ||
$this->authmanInstance = $authmanInstance; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function send(RequestInterface $request, array $options = []) { | ||
return $this->authmanInstance->authenticatedRequest($request->getMethod(), (string) $request->getUri(), $options); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function sendAsync(RequestInterface $request, array $options = []) { | ||
throw new \BadMethodCallException(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function request($method, $uri, array $options = []) { | ||
throw new \BadMethodCallException(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function requestAsync($method, $uri, array $options = []) { | ||
throw new \BadMethodCallException(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfig($option = NULL) { | ||
return $this->authmanInstance->getProvider()->getHttpClient()->getConfig($option); | ||
} | ||
|
||
} |