summaryrefslogtreecommitdiff
path: root/server/core/LibOverride/Test.php
blob: 09f08d55f5a4450f74b83cdb675ed6548ede7eee (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
64
65
66
67
68
69
70
71
72
<?php

use GuzzleHttp\Client;
use OpenStack\Common\Transport\HandlerStack;
use OpenStack\Common\Transport\Middleware;
use OpenStack\Identity\v3\Service;
use OpenStack\Common\Auth\Token;
use OpenStack\Common\Transport\Utils;

class genTokenOptions
{
	private $optionsGlobal;

	public function __construct($options, $token){
		echo "test";
		
		$stack = HandlerStack::create();
		//IdentityService?
		//	$options['IdentityService'] pas oblige?...
		//	creer HttpClient authurl HandlerStack::create()
		//	$option['identityService'] = factory httpClient
		//$httpClient = new Client([
        //    'base_uri' => Utils::normalizeUrl($options['authUrl']),
        //    'handler'  => HandlerStack::create(),
        //]);

		$httpClient = new Client([
            'base_uri' => Utils::normalizeUrl($options['authUrl']),
            'handler'  => $stack,
        ]);
		
        $options['identityService'] = Service::factory($httpClient);
		//AuthHadler?
		//	
		$options['authHandler'] = function () use ($options) {
			return $options['identityService']->generateToken($options);
        };
		//StockClient?
		//	creer $options['httpClient'] instance de ClientInterface
		//	token, baseUrl = identity->authenticate
		//	stack = getStack authhandler token
		//	addDebug??
		//	$options['httpClient'] = httpCLient baseurl stack
		$baseUrl = $options['authUrl'];
		
		//$stack = HandlerStack::create();
        $stack->push(Middleware::authHandler($options['authHandler'], $token));
		
		$this->addDebugMiddleware($options, $stack);
		
		$options['httpClient'] = $httpClient;
		
		$this->optionsGlobal = $options;
	}
 
		/**
     * @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']));
        }
    }
	
	public function getOptions(){
		return $this->optionsGlobal;
	}
}