|
1 | 1 | <?php |
| 2 | + |
2 | 3 | namespace Tmdb\SymfonyBundle; |
3 | 4 |
|
4 | | -use Doctrine\Common\Cache\Cache; |
| 5 | +use Psr\Http\Client\ClientInterface; |
| 6 | +use Psr\Http\Message\RequestFactoryInterface; |
| 7 | +use Psr\Http\Message\ResponseFactoryInterface; |
| 8 | +use Psr\Http\Message\StreamFactoryInterface; |
| 9 | +use Psr\Http\Message\UriFactoryInterface; |
5 | 10 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
6 | 11 | use Symfony\Component\HttpFoundation\ParameterBag; |
7 | 12 | use Tmdb\ConfigurationInterface; |
| 13 | +use Tmdb\Token\Api\ApiToken; |
8 | 14 |
|
9 | | -class ClientConfiguration extends ParameterBag implements ConfigurationInterface { |
| 15 | +/** |
| 16 | + * Class ClientConfiguration |
| 17 | + * @package Tmdb\SymfonyBundle |
| 18 | + */ |
| 19 | +class ClientConfiguration extends ParameterBag implements ConfigurationInterface |
| 20 | +{ |
10 | 21 | /** |
| 22 | + * ClientConfiguration constructor. |
| 23 | + * @param ApiToken $apiToken |
11 | 24 | * @param EventDispatcherInterface $eventDispatcher |
| 25 | + * @param ClientInterface $client |
| 26 | + * @param RequestFactoryInterface $requestFactory |
| 27 | + * @param ResponseFactoryInterface $responseFactory |
| 28 | + * @param StreamFactoryInterface $streamFactory |
| 29 | + * @param UriFactoryInterface $uriFactory |
12 | 30 | * @param array $options |
13 | 31 | */ |
14 | 32 | public function __construct( |
| 33 | + ApiToken $apiToken, |
15 | 34 | EventDispatcherInterface $eventDispatcher, |
| 35 | + ClientInterface $client, |
| 36 | + RequestFactoryInterface $requestFactory, |
| 37 | + ResponseFactoryInterface $responseFactory, |
| 38 | + StreamFactoryInterface $streamFactory, |
| 39 | + UriFactoryInterface $uriFactory, |
16 | 40 | array $options = [] |
17 | | - ){ |
18 | | - $this->parameters = $options; |
19 | | - |
20 | | - $this->parameters['event_dispatcher'] = $eventDispatcher; |
21 | | - } |
| 41 | + ) { |
| 42 | + $options['api_token'] = $apiToken; |
| 43 | + $options['event_dispatcher']['adapter'] = $eventDispatcher; |
| 44 | + $options['http']['client'] = $client; |
| 45 | + $options['http']['request_factory'] = $requestFactory; |
| 46 | + $options['http']['response_factory'] = $responseFactory; |
| 47 | + $options['http']['stream_factory'] = $streamFactory; |
| 48 | + $options['http']['uri_factory'] = $uriFactory; |
22 | 49 |
|
23 | | - public function setCacheHandler(Cache $handler = null) |
24 | | - { |
25 | | - $this->parameters['cache']['handler'] = $handler; |
26 | | - } |
| 50 | + // Library handles it as an api_token |
| 51 | + unset($options['bearer_token']); |
27 | 52 |
|
28 | | - /** |
29 | | - * @return array |
30 | | - */ |
31 | | - public function all() |
32 | | - { |
33 | | - return $this->parameters; |
| 53 | + parent::__construct($options); |
34 | 54 | } |
35 | 55 | } |
0 commit comments