Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

2.6.1
-----

### Fixed

* Cache Tagging: It is now possible to use cache tagging without installing the
Sensio ``FrameworkExtraBundle``. There is a new configuration option
``tags.annotations.enabled`` that can be set to ``false``.

2.6.0
-----

Expand Down
6 changes: 4 additions & 2 deletions src/DependencyInjection/Compiler/TagListenerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public function process(ContainerBuilder $container)
&& !$this->hasControllerListener($container)
) {
throw new \RuntimeException(
'Tag support requires SensioFrameworkExtraBundle’s ControllerListener for the annotations. '
.'Please install sensio/framework-extra-bundle and add it to your AppKernel.'
'Tag annotations are enabled by default because otherwise things could silently not work.'
.' The annotations require the SensioFrameworkExtraBundle ControllerListener. If you do not use'
.' annotations for tags, set "fos_http_cache.tags.annotations.enabled: false". Otherwise install'
.' sensio/framework-extra-bundle and enabled it in your kernel.'
);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,11 @@ private function addTagSection(ArrayNodeDefinition $rootNode)
->enumNode('enabled')
->values([true, false, 'auto'])
->defaultValue('auto')
->info('Allows to disable the event subscriber for tag configuration and annotations when your project does not use the annotations. Enabled by default if you configured the cache manager.')
->info('Allows to disable tag support. Enabled by default if you configured the cache manager and have a proxy client that supports tagging.')
->end()
->arrayNode('annotations')
->info('Annotations require the FrameworkExtraBundle. Because we can not detect whether annotations are used when the FrameworkExtraBundle is not available, this option must be set to false explicitly if the application does not use annotations.')
->canBeDisabled()
->end()
->booleanNode('strict')->defaultFalse()->end()
->scalarNode('expression_language')
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/FOSHttpCacheExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $lo
throw new InvalidConfigurationException(sprintf('You can not enable cache tagging with the %s client', $client));
}

$container->setParameter('fos_http_cache.compiler_pass.tag_annotations', true);
$container->setParameter('fos_http_cache.compiler_pass.tag_annotations', $config['annotations']['enabled']);
$container->setParameter('fos_http_cache.tag_handler.response_header', $config['response_header']);
$container->setParameter('fos_http_cache.tag_handler.separator', $config['separator']);
$container->setParameter('fos_http_cache.tag_handler.strict', $config['strict']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TagListenerPassTest extends TestCase

/**
* @expectedException \RuntimeException
* @expectedExceptionMessage requires SensioFrameworkExtraBundle
* @expectedExceptionMessage require the SensioFrameworkExtraBundle
*/
public function testNoFrameworkBundle()
{
Expand Down
6 changes: 6 additions & 0 deletions tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public function testSupportsAllConfigFormats()
],
'tags' => [
'enabled' => 'auto',
'annotations' => [
'enabled' => true,
],
'strict' => false,
'response_header' => 'FOS-Tags',
'expression_language' => 'acme.expression_language',
Expand Down Expand Up @@ -685,6 +688,9 @@ private function getEmptyConfig()
],
'tags' => [
'enabled' => false,
'annotations' => [
'enabled' => true,
],
'strict' => false,
'response_header' => 'X-Cache-Tags',
'expression_language' => null,
Expand Down
17 changes: 17 additions & 0 deletions tests/Unit/DependencyInjection/FOSHttpCacheExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,23 @@ public function testConfigLoadTagRules()
$this->assertRequestMatcherCreated($container, ['_controller' => '^AcmeBundle:Default:index$']);
$this->assertListenerHasRule($container, 'fos_http_cache.event_listener.tag');
$this->assertFalse($container->hasDefinition('fos_http_cache.tag_handler.max_header_value_length_header_formatter'));
$this->assertTrue($container->hasParameter('fos_http_cache.compiler_pass.tag_annotations'));
$this->assertTrue($container->getParameter('fos_http_cache.compiler_pass.tag_annotations'));
}

public function testConfigLoadTagDisableAnnotations()
{
$config = $this->getBaseConfig() + [
'tags' => [
'annotations' => false,
],
];

$container = $this->createContainer();
$this->extension->load([$config], $container);

$this->assertTrue($container->hasParameter('fos_http_cache.compiler_pass.tag_annotations'));
$this->assertFalse($container->getParameter('fos_http_cache.compiler_pass.tag_annotations'));
}

public function testConfigWithMaxHeaderLengthValueDecoratesTagService()
Expand Down