From f65e2e454ecb9fc6f6b3089159e4f5e5ef63ffb6 Mon Sep 17 00:00:00 2001 From: Aivaras Date: Thu, 10 Nov 2016 22:47:18 +0200 Subject: [PATCH] Cache pool namespace added to configuration --- .../DependencyInjection/Configuration.php | 1 + .../Resources/config/schema/symfony-1.0.xsd | 1 + .../Tests/DependencyInjection/Fixtures/php/cache.php | 2 ++ .../Tests/DependencyInjection/Fixtures/xml/cache.xml | 4 ++-- .../Tests/DependencyInjection/Fixtures/yml/cache.yml | 2 ++ .../DependencyInjection/FrameworkExtensionTest.php | 11 ++++++++--- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 708e84ad1f766..fca42dc1127ff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -680,6 +680,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode) ->scalarNode('adapter')->defaultValue('cache.app')->end() ->booleanNode('public')->defaultFalse()->end() ->integerNode('default_lifetime')->end() + ->scalarNode('namespace')->end() ->scalarNode('provider') ->info('The service name to use as provider when the specified adapter needs one.') ->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 804072e07d588..6e801d05c2d82 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -224,6 +224,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php index ef7a1be190468..6a9d7a6c8c451 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php @@ -6,6 +6,7 @@ 'cache.foo' => array( 'adapter' => 'cache.adapter.apcu', 'default_lifetime' => 30, + 'namespace' => 'foo_', ), 'cache.bar' => array( 'adapter' => 'cache.adapter.doctrine', @@ -19,6 +20,7 @@ 'cache.foobar' => array( 'adapter' => 'cache.adapter.psr6', 'default_lifetime' => 10, + 'namespace' => 'foobar_', 'provider' => 'app.cache_pool', ), 'cache.def' => array( diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml index 79ee2a4b37421..2b67488ad89f8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml @@ -7,10 +7,10 @@ - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml index 514e782e6e148..998625efe9a58 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml @@ -4,6 +4,7 @@ framework: cache.foo: adapter: cache.adapter.apcu default_lifetime: 30 + namespace: 'foo_' cache.bar: adapter: cache.adapter.doctrine default_lifetime: 5 @@ -14,6 +15,7 @@ framework: cache.foobar: adapter: cache.adapter.psr6 default_lifetime: 10 + namespace: 'foobar_' provider: app.cache_pool cache.def: default_lifetime: 11 diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 18a4829802640..ded09fe3a3de5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -638,10 +638,10 @@ public function testCachePoolServices() { $container = $this->createContainerFromFile('cache'); - $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foo', 'cache.adapter.apcu', 30); + $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foo', 'cache.adapter.apcu', 30, 'foo_'); $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.bar', 'cache.adapter.doctrine', 5); $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.baz', 'cache.adapter.filesystem', 7); - $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foobar', 'cache.adapter.psr6', 10); + $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foobar', 'cache.adapter.psr6', 10, 'foobar_'); $this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.def', 'cache.app', 11); } @@ -717,7 +717,7 @@ private function assertVersionStrategy(ContainerBuilder $container, Reference $r } } - private function assertCachePoolServiceDefinitionIsCreated(ContainerBuilder $container, $id, $adapter, $defaultLifetime) + private function assertCachePoolServiceDefinitionIsCreated(ContainerBuilder $container, $id, $adapter, $defaultLifetime, $namespace = null) { $this->assertTrue($container->has($id), sprintf('Service definition "%s" for cache pool of type "%s" is registered', $id, $adapter)); @@ -732,6 +732,11 @@ private function assertCachePoolServiceDefinitionIsCreated(ContainerBuilder $con $this->assertTrue(isset($tag[0]['default_lifetime']), 'The default lifetime is stored as an attribute of the "cache.pool" tag.'); $this->assertSame($defaultLifetime, $tag[0]['default_lifetime'], 'The default lifetime is stored as an attribute of the "cache.pool" tag.'); + if (null !== $namespace) { + $this->assertTrue(isset($tag[0]['namespace']), 'The namespace is stored as an attribute of the "cache.pool" tag.'); + $this->assertSame($namespace, $tag[0]['namespace'], 'The namespace is stored as an attribute of the "cache.pool" tag.'); + } + $parentDefinition = $poolDefinition; do { $parentId = $parentDefinition->getParent();