Skip to content

Commit

Permalink
Merge pull request #12 from santakadev/master
Browse files Browse the repository at this point in the history
  • Loading branch information
EugenGanshorn authored Sep 20, 2023
2 parents 96fdce2 + 368c8f7 commit 46d8325
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,8 @@ $ composer require eugenganshorn/guzzle-bundle-retry-plugin
## Usage
### Enable bundle

#### Symfony 2.x and 3.x
Plugin will be activated/connected through bundle constructor in `app/AppKernel.php`, like this:

``` php
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([
new EugenGanshorn\Bundle\GuzzleBundleRetryPlugin\GuzzleBundleRetryPlugin(),
])
```

#### 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.
Plugin will be activated/connected through bundle constructor in `app/AppKernel.php`, like this:
Find next lines:

```php
Expand All @@ -62,6 +53,26 @@ foreach ($contents as $class => $envs) {
}
}
```
#### Symfony 5 & 6
Override the `registerBundles` method in `src/Kernel.php` to connect the plugin to the bundle:

```php
public function registerBundles(): iterable
{
$contents = require $this->getBundlesPath();
foreach ($contents as $class => $envs) {
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
if ($class === EightPointsGuzzleBundle::class) {
yield new $class([
new GuzzleBundleRetryPlugin(),
]);
} else {
yield new $class();
}
}
}
}
```

### Basic configuration
``` yaml
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"guzzlehttp/guzzle": "^6.3|^7.0",
"eightpoints/guzzle-bundle": "^7.6|^8.0",
"caseyamcl/guzzle_retry_middleware": "^2.2",
"symfony/dependency-injection": "~4.0|^5.0"
"symfony/dependency-injection": "^4.0|^5.0|^6.0"
},
"require-dev": {
"phpunit/phpunit": "^8.1",
Expand Down

0 comments on commit 46d8325

Please sign in to comment.