Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 31159f3

Browse filesBrowse files
[FrameworkBundle] More explicit cache pool config
1 parent b0a0829 commit 31159f3
Copy full SHA for 31159f3

File tree

15 files changed

+72
-91
lines changed
Filter options

15 files changed

+72
-91
lines changed

‎UPGRADE-3.1.md

Copy file name to clipboardExpand all lines: UPGRADE-3.1.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ FrameworkBundle
9090
cache service. If you are using `serializer.mapping.cache.apc`, use
9191
`serializer.mapping.cache.doctrine.apc` instead.
9292

93-
* The `framework.serializer.cache` option has been deprecated. Configure a cache pool
94-
called `serializer` under `framework.cache.pools` instead.
93+
* The `framework.serializer.cache` option has been deprecated. Configure the
94+
`cache.serializer` service under `framework.cache.pools` instead.
9595

9696
Before:
9797

@@ -107,7 +107,7 @@ FrameworkBundle
107107
framework:
108108
cache:
109109
pools:
110-
serializer:
110+
cache.serializer:
111111
adapter: cache.adapter.apcu
112112

113113
HttpKernel

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ FrameworkBundle
7878
* The service `serializer.mapping.cache.apc` has been removed; use
7979
`serializer.mapping.cache.doctrine.apc` instead.
8080

81-
* The `framework.serializer.cache` option has been removed. Configure a cache pool
82-
called `serializer` under `framework.cache.pools` instead.
81+
* The `framework.serializer.cache` option has been removed. Configure the
82+
`cache.serializer` service under `framework.cache.pools` instead.
8383

8484
Before:
8585

@@ -95,7 +95,7 @@ FrameworkBundle
9595
framework:
9696
cache:
9797
pools:
98-
serializer:
98+
cache.serializer:
9999
adapter: cache.adapter.apcu
100100
```
101101

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+15-18Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -557,34 +557,31 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
557557
->info('Cache configuration')
558558
->addDefaultsIfNotSet()
559559
->fixXmlConfig('pool')
560-
->fixXmlConfig('adapter')
561560
->children()
562-
->arrayNode('adapters')
561+
->arrayNode('pools')
563562
->useAttributeAsKey('name')
564563
->prototype('array')
564+
->validate()
565+
->ifTrue(function ($v) { return isset($v['parent'], $v['adapter']); })
566+
->thenInvalid('You cannot configure both "parent" and "adapter" options.')
567+
->end()
568+
->validate()
569+
->ifTrue(function ($v) { return !isset($v['adapter']); })
570+
->then(function ($v) { $v['adapter'] = 'cache.adapter.shared'; return $v; })
571+
->end()
565572
->children()
566573
->scalarNode('parent')
567-
->isRequired()
568-
->info('The parent cache adapter service.')
574+
->info('To create a new adapter based on this parent service.')
569575
->end()
570-
->integerNode('default_lifetime')->end()
571-
->scalarNode('provider')
572-
->info('The service name to use as provider when the specified parent adapter needs one.')
573-
->end()
574-
->scalarNode('clearer')->defaultValue('cache.default_pools_clearer')->end()
575-
->end()
576-
->end()
577-
->end()
578-
->arrayNode('pools')
579-
->useAttributeAsKey('name')
580-
->prototype('array')
581-
->children()
582576
->scalarNode('adapter')
583-
->info('The cache adapter service to use as template definition.')
584-
->defaultValue('cache.adapter.shared')
577+
->info('The create a new pool based on this adapter service.')
585578
->end()
586579
->booleanNode('public')->defaultTrue()->end()
580+
->scalarNode('provider')
581+
->info('The service name to use as provider when the specified parent or adapter needs one.')
582+
->end()
587583
->integerNode('default_lifetime')->end()
584+
->scalarNode('clearer')->defaultValue('cache.default_pools_clearer')->end()
588585
->end()
589586
->end()
590587
->end()

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+11-15Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
984984
$chainLoader->replaceArgument(0, $serializerLoaders);
985985

986986
if (isset($config['cache']) && $config['cache']) {
987-
@trigger_error('The "framework.serializer.cache" option is deprecated since Symfony 3.1 and will be removed in 4.0. You can configure a cache pool called "serializer" under "framework.cache.pools" instead.', E_USER_DEPRECATED);
987+
@trigger_error('The "framework.serializer.cache" option is deprecated since Symfony 3.1 and will be removed in 4.0. Configure the "cache.serializer" service under "framework.cache.pools" instead.', E_USER_DEPRECATED);
988988

989989
$container->setParameter(
990990
'serializer.mapping.cache.prefix',
@@ -999,7 +999,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
999999
CacheClassMetadataFactory::class,
10001000
array(
10011001
new Reference('serializer.mapping.cache_class_metadata_factory.inner'),
1002-
new Reference('cache.pool.serializer'),
1002+
new Reference('cache.serializer'),
10031003
)
10041004
);
10051005
$cacheMetadataFactory->setPublic(false);
@@ -1037,22 +1037,18 @@ private function registerPropertyInfoConfiguration(array $config, ContainerBuild
10371037

10381038
private function registerCacheConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
10391039
{
1040-
foreach ($config['adapters'] as $name => $adapterConfig) {
1041-
$adapterDefinition = new DefinitionDecorator($adapterConfig['parent']);
1042-
$adapterDefinition->setAbstract(true);
1043-
unset($adapterConfig['parent']);
1044-
1045-
$adapterDefinition->addTag('cache.pool', $adapterConfig);
1046-
$container->setDefinition('cache.adapter.'.$name, $adapterDefinition);
1047-
}
1048-
10491040
foreach ($config['pools'] as $name => $poolConfig) {
1050-
$poolDefinition = new DefinitionDecorator($poolConfig['adapter']);
1051-
$poolDefinition->setPublic($poolConfig['public']);
1052-
unset($poolConfig['adapter'], $poolConfig['public']);
1041+
if (isset($poolConfig['parent'])) {
1042+
$poolDefinition = new DefinitionDecorator($poolConfig['parent']);
1043+
$poolDefinition->setAbstract(true);
1044+
} else {
1045+
$poolDefinition = new DefinitionDecorator($poolConfig['adapter']);
1046+
$poolDefinition->setPublic($poolConfig['public']);
1047+
}
1048+
unset($poolConfig['parent'], $poolConfig['adapter'], $poolConfig['public']);
10531049

10541050
$poolDefinition->addTag('cache.pool', $poolConfig);
1055-
$container->setDefinition('cache.pool.'.$name, $poolDefinition);
1051+
$container->setDefinition($name, $poolDefinition);
10561052
}
10571053

10581054
$this->addClassesToCompile(array(

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/cache_pools.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/cache_pools.xml
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
<tag name="kernel.cache_clearer" />
1111
</service>
1212

13-
<service id="cache.pool.app" parent="cache.adapter.shared">
13+
<service id="cache.app" parent="cache.adapter.shared">
1414
<tag name="cache.pool" />
1515
</service>
1616

17-
<service id="cache.pool.validator" parent="cache.adapter.local" public="false">
17+
<service id="cache.validator" parent="cache.adapter.local" public="false">
1818
<tag name="cache.pool" />
1919
</service>
2020

21-
<service id="cache.pool.serializer" parent="cache.adapter.local" public="false">
21+
<service id="cache.serializer" parent="cache.adapter.local" public="false">
2222
<tag name="cache.pool" />
2323
</service>
2424

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+3-9Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,23 +206,17 @@
206206

207207
<xsd:complexType name="cache">
208208
<xsd:choice minOccurs="1" maxOccurs="unbounded">
209-
<xsd:element name="adapter" type="cache_adapter" />
210209
<xsd:element name="pool" type="cache_pool" />
211210
</xsd:choice>
212211
</xsd:complexType>
213212

214-
<xsd:complexType name="cache_adapter">
215-
<xsd:attribute name="name" type="xsd:string" use="required" />
216-
<xsd:attribute name="parent" type="xsd:string" />
217-
<xsd:attribute name="default-lifetime" type="xsd:integer" />
218-
<xsd:attribute name="provider" type="xsd:string" />
219-
<xsd:attribute name="clearer" type="xsd:string" />
220-
</xsd:complexType>
221-
222213
<xsd:complexType name="cache_pool">
223214
<xsd:attribute name="name" type="xsd:string" use="required" />
215+
<xsd:attribute name="parent" type="xsd:string" />
224216
<xsd:attribute name="adapter" type="xsd:string" />
225217
<xsd:attribute name="public" type="xsd:boolean" />
218+
<xsd:attribute name="provider" type="xsd:string" />
226219
<xsd:attribute name="default-lifetime" type="xsd:integer" />
220+
<xsd:attribute name="clearer" type="xsd:string" />
227221
</xsd:complexType>
228222
</xsd:schema>

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<service id="validator.mapping.class_metadata_factory" alias="validator" public="false" />
3030

3131
<service id="validator.mapping.cache.symfony" class="Symfony\Component\Validator\Mapping\Cache\Psr6Cache" public="false">
32-
<argument type="service" id="cache.pool.validator" />
32+
<argument type="service" id="cache.validator" />
3333
</service>
3434

3535
<service id="validator.mapping.cache.doctrine.apc" class="Symfony\Component\Validator\Mapping\Cache\DoctrineCache" public="false">

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ protected static function getBundleDefaultConfig()
267267
'packages' => array(),
268268
),
269269
'cache' => array(
270-
'adapters' => array(),
271270
'pools' => array(),
272271
),
273272
);

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php
+8-10Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,33 @@
22

33
$container->loadFromExtension('framework', array(
44
'cache' => array(
5-
'adapters' => array(
6-
'foo' => array(
5+
'pools' => array(
6+
'cache.adapter.foo' => array(
77
'parent' => 'cache.adapter.filesystem',
88
'default_lifetime' => 30,
99
),
10-
'app_redis' => array(
10+
'cache.adapter.app_redis' => array(
1111
'parent' => 'cache.adapter.redis',
1212
'provider' => 'app.redis_connection',
1313
'default_lifetime' => 30,
1414
),
15-
),
16-
'pools' => array(
17-
'foo' => array(
15+
'cache.foo' => array(
1816
'adapter' => 'cache.adapter.apcu',
1917
'default_lifetime' => 30,
2018
),
21-
'bar' => array(
19+
'cache.bar' => array(
2220
'adapter' => 'cache.adapter.doctrine',
2321
'default_lifetime' => 5,
2422
),
25-
'baz' => array(
23+
'cache.baz' => array(
2624
'adapter' => 'cache.adapter.filesystem',
2725
'default_lifetime' => 7,
2826
),
29-
'foobar' => array(
27+
'cache.foobar' => array(
3028
'adapter' => 'cache.adapter.psr6',
3129
'default_lifetime' => 10,
3230
),
33-
'def' => array(
31+
'cache.def' => array(
3432
'default_lifetime' => 11,
3533
),
3634
),

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
<framework:config>
99
<framework:cache>
10-
<framework:adapter name="foo" parent="cache.adapter.filesystem" default-lifetime="30" />
11-
<framework:adapter name="app_redis" parent="cache.adapter.redis" provider="app.redis_connection" default-lifetime="30" />
12-
<framework:pool name="foo" adapter="cache.adapter.apcu" default-lifetime="30" />
13-
<framework:pool name="bar" adapter="cache.adapter.doctrine" default-lifetime="5" />
14-
<framework:pool name="baz" adapter="cache.adapter.filesystem" default-lifetime="7" />
15-
<framework:pool name="foobar" adapter="cache.adapter.psr6" default-lifetime="10" />
16-
<framework:pool name="def" default-lifetime="11" />
10+
<framework:pool name="cache.adapter.foo" parent="cache.adapter.filesystem" default-lifetime="30" />
11+
<framework:pool name="cache.adapter.app_redis" parent="cache.adapter.redis" provider="app.redis_connection" default-lifetime="30" />
12+
<framework:pool name="cache.foo" adapter="cache.adapter.apcu" default-lifetime="30" />
13+
<framework:pool name="cache.bar" adapter="cache.adapter.doctrine" default-lifetime="5" />
14+
<framework:pool name="cache.baz" adapter="cache.adapter.filesystem" default-lifetime="7" />
15+
<framework:pool name="cache.foobar" adapter="cache.adapter.psr6" default-lifetime="10" />
16+
<framework:pool name="cache.def" default-lifetime="11" />
1717
</framework:cache>
1818
</framework:config>
1919
</container>
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
framework:
22
cache:
3-
adapters:
4-
foo:
3+
pools:
4+
cache.adapter.foo:
55
parent: cache.adapter.filesystem
66
default_lifetime: 30
7-
app_redis:
7+
cache.adapter.app_redis:
88
parent: cache.adapter.redis
99
provider: app.redis_connection
1010
default_lifetime: 30
11-
pools:
12-
foo:
11+
cache.foo:
1312
adapter: cache.adapter.apcu
1413
default_lifetime: 30
15-
bar:
14+
cache.bar:
1615
adapter: cache.adapter.doctrine
1716
default_lifetime: 5
18-
baz:
17+
cache.baz:
1918
adapter: cache.adapter.filesystem
2019
default_lifetime: 7
21-
foobar:
20+
cache.foobar:
2221
adapter: cache.adapter.psr6
2322
default_lifetime: 10
24-
def:
23+
cache.def:
2524
default_lifetime: 11

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,11 @@ public function testCachePoolServices()
627627
{
628628
$container = $this->createContainerFromFile('cache');
629629

630-
$this->assertCachePoolServiceDefinitionIsCreated($container, 'foo', 'cache.adapter.apcu', 30);
631-
$this->assertCachePoolServiceDefinitionIsCreated($container, 'bar', 'cache.adapter.doctrine', 5);
632-
$this->assertCachePoolServiceDefinitionIsCreated($container, 'baz', 'cache.adapter.filesystem', 7);
633-
$this->assertCachePoolServiceDefinitionIsCreated($container, 'foobar', 'cache.adapter.psr6', 10);
634-
$this->assertCachePoolServiceDefinitionIsCreated($container, 'def', 'cache.adapter.filesystem', 11);
630+
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foo', 'cache.adapter.apcu', 30);
631+
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.bar', 'cache.adapter.doctrine', 5);
632+
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.baz', 'cache.adapter.filesystem', 7);
633+
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foobar', 'cache.adapter.psr6', 10);
634+
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.def', 'cache.adapter.filesystem', 11);
635635
}
636636

637637
protected function createContainer(array $data = array())
@@ -745,15 +745,13 @@ private function assertCacheAdaptersServiceDefinitionIsCreated(ContainerBuilder
745745
}
746746
}
747747

748-
private function assertCachePoolServiceDefinitionIsCreated(ContainerBuilder $container, $name, $adapter, $defaultLifetime)
748+
private function assertCachePoolServiceDefinitionIsCreated(ContainerBuilder $container, $id, $adapter, $defaultLifetime)
749749
{
750-
$id = 'cache.pool.'.$name;
751-
752750
$this->assertTrue($container->has($id), sprintf('Service definition "%s" for cache pool of type "%s" is registered', $id, $adapter));
753751

754752
$poolDefinition = $container->getDefinition($id);
755753

756-
$this->assertInstanceOf(DefinitionDecorator::class, $poolDefinition, sprintf('Cache pool "%s" is based on an abstract cache pool.', $name));
754+
$this->assertInstanceOf(DefinitionDecorator::class, $poolDefinition, sprintf('Cache pool "%s" is based on an abstract cache pool.', $id));
757755

758756
$this->assertTrue($poolDefinition->hasTag('cache.pool'), sprintf('Service definition "%s" is tagged with the "cache.pool" tag.', $id));
759757
$this->assertFalse($poolDefinition->isAbstract(), sprintf('Service definition "%s" is not abstract.', $id));

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function doTestCachePools($options, $adapterClass)
4141
static::bootKernel($options);
4242
$container = static::$kernel->getContainer();
4343

44-
$pool = $container->get('cache.pool.test');
44+
$pool = $container->get('cache.test');
4545
$this->assertInstanceOf($adapterClass, $pool);
4646

4747
$key = 'foobar';

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ imports:
44
framework:
55
cache:
66
pools:
7-
test:
7+
cache.test:
88
public: true

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ services:
1818
framework:
1919
cache:
2020
pools:
21-
test:
21+
cache.test:
2222
public: true

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.