Skip to content

Commit aa20b2a

Browse files
committed
Merge pull request #236 from FriendsOfSymfony/fix-custom-client-config
fix how to configure a custom proxy client for the cache manager
2 parents ae7aca7 + c17eced commit aa20b2a

File tree

5 files changed

+49
-4
lines changed

5 files changed

+49
-4
lines changed

DependencyInjection/Configuration.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ public function getConfigTreeBuilder()
5252

5353
$rootNode
5454
->validate()
55-
->ifTrue(function ($v) {return $v['cache_manager']['enabled'] && !isset($v['proxy_client']);})
55+
->ifTrue(function ($v) {
56+
return $v['cache_manager']['enabled']
57+
&& !isset($v['proxy_client'])
58+
&& !isset($v['cache_manager']['custom_proxy_client'])
59+
;
60+
})
5661
->then(function ($v) {
57-
if (!empty($v['cache_manager']['proxy_client'])) {
58-
return $v;
59-
}
6062
if ('auto' === $v['cache_manager']['enabled']) {
6163
$v['cache_manager']['enabled'] = false;
6264

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
$container->loadFromExtension('fos_http_cache', array(
4+
'cache_manager' => array(
5+
'enabled' => true,
6+
'custom_proxy_client' => 'acme.proxy_client',
7+
),
8+
));
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services">
3+
4+
<config xmlns="http://example.org/schema/dic/fos_http_cache">
5+
<cache-manager enabled="true" custom-proxy-client="acme.proxy_client"/>
6+
</config>
7+
</container>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fos_http_cache:
2+
cache_manager:
3+
enabled: true
4+
custom_proxy_client: acme.proxy_client

Tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,30 @@ public function testSupportsAllConfigFormats()
184184
}
185185
}
186186

187+
public function testCustomProxyClient()
188+
{
189+
$expectedConfiguration = $this->getEmptyConfig();
190+
$expectedConfiguration['cache_manager'] = array(
191+
'enabled' => true,
192+
'custom_proxy_client' => 'acme.proxy_client',
193+
'generate_url_type' => 'auto',
194+
);
195+
$expectedConfiguration['tags']['enabled'] = 'auto';
196+
$expectedConfiguration['invalidation']['enabled'] = 'auto';
197+
198+
$formats = array_map(function ($path) {
199+
return __DIR__.'/../../Resources/Fixtures/'.$path;
200+
}, array(
201+
'config/custom-client.yml',
202+
'config/custom-client.xml',
203+
'config/custom-client.php',
204+
));
205+
206+
foreach ($formats as $format) {
207+
$this->assertProcessedConfigurationEquals($expectedConfiguration, array($format));
208+
}
209+
}
210+
187211
public function testSupportsNginx()
188212
{
189213
$expectedConfiguration = $this->getEmptyConfig();

0 commit comments

Comments
 (0)