Skip to content

Make tags header configurable #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ private function addTagSection(ArrayNodeDefinition $rootNode)
->defaultValue('auto')
->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.')
->end()
->scalarNode('header')
->defaultValue('X-Cache-Tags')
->info('HTTP header that contains cache tags')
->end()
->arrayNode('rules')
->prototype('array')
->fixXmlConfig('tag')
Expand Down
6 changes: 5 additions & 1 deletion DependencyInjection/FOSHttpCacheExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\HttpKernel\Kernel;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unused.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could run the php-cs-fixer again at some point to eliminate all unused imports.

/**
* {@inheritdoc}
Expand Down Expand Up @@ -74,6 +73,11 @@ public function load(array $configs, ContainerBuilder $container)
// silently skip if set to auto
throw new InvalidConfigurationException('The TagSubscriber requires symfony/expression-language and needs the cache_manager to be configured');
}

$tagsHeader = $config['tags']['header'];
$container->getDefinition($this->getAlias().'.cache_manager')
->addMethodCall('setTagsHeader', array($tagsHeader))
;
}

if ($config['invalidation']['enabled']) {
Expand Down
1 change: 1 addition & 0 deletions Tests/Resources/Fixtures/config/full.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'enabled' => true,
),
'tags' => array(
'header' => 'FOS-Tags',
'rules' => array(
array(
'match' => array(
Expand Down
2 changes: 1 addition & 1 deletion Tests/Resources/Fixtures/config/full.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<cache-manager enabled="true"/>

<tags>
<tags header="FOS-Tags">
<rule>
<match path="/def" host="friends">
<method>PUT</method>
Expand Down
1 change: 1 addition & 0 deletions Tests/Resources/Fixtures/config/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fos_http_cache:
enabled: true

tags:
header: FOS-Tags
rules:
-
match:
Expand Down
2 changes: 2 additions & 0 deletions Tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function testSupportsAllConfigFormats()
),
'tags' => array(
'enabled' => 'auto',
'header' => 'FOS-Tags',
'rules' => array(
array(
'match' => array(
Expand Down Expand Up @@ -410,6 +411,7 @@ private function getEmptyConfig()
),
'tags' => array(
'enabled' => false,
'header' => 'X-Cache-Tags',
'rules' => array(),
),
'invalidation' => array(
Expand Down