Skip to content

Commit cdb291f

Browse files
ddeboerdbu
authored andcommitted
Make tags header configurable (fix #73)
1 parent 4f4bcea commit cdb291f

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ private function addTagSection(ArrayNodeDefinition $rootNode)
326326
->defaultValue('auto')
327327
->info('Allows to disable the listener for tag annotations when your project does not use the annotations. Enabled by default if you have expression language and the cache manager.')
328328
->end()
329+
->scalarNode('header')
330+
->defaultValue('X-Cache-Tags')
331+
->info('HTTP header that contains cache tags')
332+
->end()
329333
->arrayNode('rules')
330334
->prototype('array')
331335
->fixXmlConfig('tag')

DependencyInjection/FOSHttpCacheExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2020
use Symfony\Component\DependencyInjection\Reference;
2121
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
22-
use Symfony\Component\HttpKernel\Kernel;
2322

2423
/**
2524
* {@inheritdoc}
@@ -74,6 +73,11 @@ public function load(array $configs, ContainerBuilder $container)
7473
// silently skip if set to auto
7574
throw new InvalidConfigurationException('The TagSubscriber requires symfony/expression-language and needs the cache_manager to be configured');
7675
}
76+
77+
$tagsHeader = $config['tags']['header'];
78+
$container->getDefinition($this->getAlias().'.cache_manager')
79+
->addMethodCall('setTagsHeader', array($tagsHeader))
80+
;
7781
}
7882

7983
if ($config['invalidation']['enabled']) {

Tests/Resources/Fixtures/config/full.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
'enabled' => true,
4444
),
4545
'tags' => array(
46+
'header' => 'FOS-Tags',
4647
'rules' => array(
4748
array(
4849
'match' => array(

Tests/Resources/Fixtures/config/full.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ fos_http_cache:
4343
enabled: true
4444

4545
tags:
46+
header: FOS-Tags
4647
rules:
4748
-
4849
match:

Tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function testSupportsAllConfigFormats()
9292
),
9393
'tags' => array(
9494
'enabled' => 'auto',
95+
'header' => 'FOS-Tags',
9596
'rules' => array(
9697
array(
9798
'match' => array(
@@ -410,6 +411,7 @@ private function getEmptyConfig()
410411
),
411412
'tags' => array(
412413
'enabled' => false,
414+
'header' => 'X-Cache-Tags',
413415
'rules' => array(),
414416
),
415417
'invalidation' => array(

0 commit comments

Comments
 (0)