Skip to content

Commit

Permalink
Merge pull request #197 from gregurco/plugins_in_sf4
Browse files Browse the repository at this point in the history
Plugins in SF4
  • Loading branch information
gregurco committed May 3, 2018
2 parents 1f4c900 + 1ec5b2d commit 5ec462b
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,44 @@ $response = $client->get('/users');
This bundle allows to register and integrate plugins to extend functionality of guzzle and this bundle.

### Usage

#### Symfony 2.x and 3.x
All plugins will be activated/connected through bundle constructor in AppKernel, like this:

``` php
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([
new Gregurco\Bundle\GuzzleBundleWssePlugin\GuzzleBundleWssePlugin(),
new Gregurco\Bundle\GuzzleBundleOAuth2Plugin\GuzzleBundleOAuth2Plugin(),
])
```

#### Symfony 4
The registration of bundles was changed in Symfony 4 and now you have to change `src/Kernel.php` to achieve the same functionality.
Find next lines:

```php
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();
}
}
```

and replace them by:

```php
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
if ($class === \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle::class) {
yield new $class([
new \Gregurco\Bundle\GuzzleBundleOAuth2Plugin\GuzzleBundleOAuth2Plugin(),
]);
} else {
yield new $class();
}
}
}
```

### Known and Supported Plugins
- [gregurco/GuzzleBundleWssePlugin][6]
- [gregurco/GuzzleBundleCachePlugin][7]
Expand Down

0 comments on commit 5ec462b

Please sign in to comment.