blob: a1c802336e27a075d99c8ae424378667525054ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
class genTokenOptions
{
private $clientHTTP;
public function __construct(){
//IdentityService?
// $options['IdentityService'] pas oblige?...
// creer HttpClient authurl HandlerStack::create()
// $option['identityService'] = factory httpClient
//AuthHadler?
//
//StockClient?
// creer $options['httpClient'] instance de ClientInterface
// token, baseUrl = identity->authenticate
// stack = getStack authhandler token
// addDebug??
// $options['httpClient'] = httpCLient baseurl stack
}
/**
* @codeCoverageIgnore
*/
private function addDebugMiddleware(array $options, HandlerStack &$stack)
{
if (!empty($options['debugLog'])
&& !empty($options['logger'])
&& !empty($options['messageFormatter'])
) {
$stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
}
}
/**
* @param array $options
* @codeCoverageIgnore
*/
private function stockAuthHandler(array &$options)
{
if (!isset($options['authHandler'])) {
$options['authHandler'] = function () use ($options) {
return $options['identityService']->generateToken($options);
};
}
}
private function getStack(callable $authHandler, Token $token = null)
{
$stack = HandlerStack::create();
$stack->push(Middleware::authHandler($authHandler, $token));
return $stack;
}
private function httpClient($baseUrl, HandlerStack $stack)
{
return new Client([
'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack,
]);
}
}
|