Skip to content

Commit 48d2479

Browse files
committed
cache-plugin is not a hard dependency to use this bundle
1 parent 8b7cb00 commit 48d2479

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
1313
### Changed
1414

1515
- Removed `twig/twig` dependency
16+
- Removed hard dependency on `php-http/cache-plugin`. If you want to use the
17+
caching plugin, you need to require it in your project.
1618

1719
## 1.14.0
1820

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ private function createCachePluginNode()
700700
$cache = $builder->root('cache');
701701
$cache
702702
->canBeEnabled()
703+
->info('Configure HTTP caching, requires the php-http/cache-plugin package')
703704
->addDefaultsIfNotSet()
704705
->children()
705706
->scalarNode('cache_pool')

DependencyInjection/HttplugExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Http\Client\Common\HttpMethodsClient;
99
use Http\Client\Common\HttpMethodsClientInterface;
1010
use Http\Client\Common\Plugin\AuthenticationPlugin;
11+
use Http\Client\Common\Plugin\CachePlugin;
1112
use Http\Client\Common\PluginClient;
1213
use Http\Client\Common\PluginClientFactory;
1314
use Http\Client\HttpClient;
@@ -17,6 +18,7 @@
1718
use Http\Message\Authentication\Wsse;
1819
use Http\Mock\Client as MockClient;
1920
use Psr\Http\Message\UriInterface;
21+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
2022
use Symfony\Component\Config\FileLocator;
2123
use Symfony\Component\DependencyInjection\Alias;
2224
use Symfony\Component\DependencyInjection\ChildDefinition;
@@ -175,6 +177,9 @@ private function configurePluginByName($name, Definition $definition, array $con
175177
{
176178
switch ($name) {
177179
case 'cache':
180+
if (!class_exists(CachePlugin::class)) {
181+
throw new InvalidConfigurationException('To use the cache plugin, you need to require php-http/cache-plugin in your project');
182+
}
178183
$options = $config['config'];
179184
if (!empty($options['cache_key_generator'])) {
180185
$options['cache_key_generator'] = new Reference($options['cache_key_generator']);

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"guzzlehttp/psr7": "^1.0",
3838
"matthiasnoback/symfony-dependency-injection-test": "^1.1 || ^2.3",
3939
"nyholm/nsa": "^1.1",
40+
"php-http/cache-plugin": "^1.6",
4041
"php-http/guzzle6-adapter": "^1.1.1 || ^2.0.1",
4142
"php-http/promise": "^1.0",
4243
"php-http/mock-client": "^1.2",
@@ -57,6 +58,7 @@
5758
},
5859
"suggest": {
5960
"twig/twig": "Add this to your require-dev section when using the WebProfilerBundle",
61+
"php-http/cache-plugin": "To configure clients that cache responses",
6062
"php-http/mock-client": "Add this to your require-dev section to mock HTTP responses easily"
6163
},
6264
"autoload": {

0 commit comments

Comments
 (0)