Skip to content

Commit

Permalink
Merge pull request #15 from bookboon/hotfix/handler-stack
Browse files Browse the repository at this point in the history
feat: support injecting handlerstack through di
  • Loading branch information
lkm authored May 10, 2021
2 parents 6e6e738 + 0900cb3 commit f08237b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ services:
- 'api'
- 1800

bookboon.handlerstack:
class: GuzzleHttp\HandlerStack
factory: ['GuzzleHttp\HandlerStack', 'create']

Bookboon\Api\Bookboon:
public: true
lazy: true
Expand All @@ -15,5 +19,6 @@ services:
- '@Bookboon\ApiBundle\Helper\ConfigurationHolder'
- '@bookboon.cache'
- '@monolog.logger.api'
- '@bookboon.handlerstack'
tags:
- { name: monolog.logger, channel: api }
12 changes: 9 additions & 3 deletions Service/ApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Bookboon\Api\Client\Oauth\OauthGrants;
use Bookboon\Api\Client\OauthClient;
use Bookboon\ApiBundle\Helper\ConfigurationHolder;
use GuzzleHttp\HandlerStack;
use Psr\Log\LoggerInterface;
use Psr\SimpleCache\CacheInterface;

Expand All @@ -19,8 +20,12 @@ class ApiFactory
* @return Bookboon
* @throws \Bookboon\Api\Exception\UsageException
*/
public static function create(ConfigurationHolder $config, CacheInterface $cache, LoggerInterface $logger)
{
public static function create(
ConfigurationHolder $config,
CacheInterface $cache,
LoggerInterface $logger,
HandlerStack $stack
) {
$bookboon = new Bookboon(
new OauthClient(
$config->getId(),
Expand All @@ -32,7 +37,8 @@ public static function create(ConfigurationHolder $config, CacheInterface $cache
null,
$config->getOverrideAuthUri(),
$config->getOverrideApiUri(),
$logger
$logger,
['handler' => $stack]
)
);

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"symfony/dependency-injection": "^4.0|^5.0",
"symfony/config": "^4.0|^5.0",
"symfony/cache": "^4.0|^5.0",
"bookboon/api": "~4.0"
"bookboon/api": "~4.12"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit f08237b

Please sign in to comment.