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 4152634

Browse filesBrowse files
[FrameworkBundle] Add default pool & system adapter
1 parent 714b916 commit 4152634
Copy full SHA for 4152634

File tree

11 files changed

+44
-18
lines changed
Filter options

11 files changed

+44
-18
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function process(ContainerBuilder $container)
6363
unset($tags[0][$attr]);
6464
}
6565
if (!empty($tags[0])) {
66-
throw new \InvalidArgumentException(sprintf('Invalid "cache.pool" tag for service "%s": accepted attributes are "provider", "namespace" and "default_lifetime", found "%s".', $id, implode('", "', array_keys($tags[0]))));
66+
throw new \InvalidArgumentException(sprintf('Invalid "cache.pool" tag for service "%s": accepted attributes are "clearer", "provider", "namespace" and "default_lifetime", found "%s".', $id, implode('", "', array_keys($tags[0]))));
6767
}
6868

6969
if (null !== $clearer) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
555555
->children()
556556
->arrayNode('cache')
557557
->info('Cache configuration')
558+
->addDefaultsIfNotSet()
558559
->fixXmlConfig('pool')
559560
->children()
560561
->arrayNode('pools')
@@ -563,7 +564,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
563564
->children()
564565
->scalarNode('adapter')
565566
->info('The cache pool adapter service to use as template definition.')
566-
->defaultValue('cache.adapter.default')
567+
->defaultValue('cache.adapter.shared')
567568
->end()
568569
->booleanNode('public')->defaultFalse()->end()
569570
->integerNode('default_lifetime')->end()

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public function load(array $configs, ContainerBuilder $container)
122122
$this->registerFragmentsConfiguration($config['fragments'], $container, $loader);
123123
$this->registerTranslatorConfiguration($config['translator'], $container);
124124
$this->registerProfilerConfiguration($config['profiler'], $container, $loader);
125+
$this->registerCacheConfiguration($config['cache'], $container, $loader);
125126

126127
if ($this->isConfigEnabled($container, $config['router'])) {
127128
$this->registerRouterConfiguration($config['router'], $container, $loader);
@@ -138,10 +139,6 @@ public function load(array $configs, ContainerBuilder $container)
138139
$this->registerPropertyInfoConfiguration($config['property_info'], $container, $loader);
139140
}
140141

141-
if (isset($config['cache'])) {
142-
$this->registerCacheConfiguration($config['cache'], $container, $loader);
143-
}
144-
145142
$loader->load('debug_prod.xml');
146143
$definition = $container->findDefinition('debug.debug_handlers_listener');
147144

@@ -1022,9 +1019,7 @@ private function registerPropertyInfoConfiguration(array $config, ContainerBuild
10221019

10231020
private function registerCacheConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
10241021
{
1025-
if (!empty($config['pools'])) {
1026-
$loader->load('cache_pools.xml');
1027-
}
1022+
$loader->load('cache_pools.xml');
10281023

10291024
foreach ($config['pools'] as $name => $poolConfig) {
10301025
$poolDefinition = new DefinitionDecorator($poolConfig['adapter']);
@@ -1034,6 +1029,14 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
10341029
$poolDefinition->addTag('cache.pool', $poolConfig);
10351030
$container->setDefinition('cache.pool.'.$name, $poolDefinition);
10361031
}
1032+
1033+
$this->addClassesToCompile(array(
1034+
'Psr\Cache\CacheItemInterface',
1035+
'Psr\Cache\CacheItemPoolInterface',
1036+
'Symfony\Component\Cache\Adapter\AdapterInterface',
1037+
'Symfony\Component\Cache\Adapter\AbstractAdapter',
1038+
'Symfony\Component\Cache\CacheItem',
1039+
));
10371040
}
10381041

10391042
/**

‎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
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@
1010
<tag name="kernel.cache_clearer" />
1111
</service>
1212

13-
<service id="cache.adapter.default" alias="cache.adapter.filesystem" />
13+
<service id="cache.adapter.shared" alias="cache.adapter.filesystem" />
14+
<service id="cache.adapter.local" alias="cache.adapter.filesystem" />
15+
16+
<service id="cache.pool.shared" parent="cache.adapter.shared">
17+
<tag name="cache.pool" clearer="cache.default_pools_clearer" />
18+
</service>
19+
20+
<service id="cache.pool.local" parent="cache.adapter.local">
21+
<tag name="cache.pool" clearer="cache.default_pools_clearer" />
22+
</service>
1423

1524
<service id="cache.adapter.apcu" class="Symfony\Component\Cache\Adapter\ApcuAdapter" abstract="true">
1625
<argument /> <!-- namespace -->

‎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
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@
216216
<xsd:attribute name="public" type="xsd:boolean" />
217217
<xsd:attribute name="default-lifetime" type="xsd:integer" />
218218
<xsd:attribute name="provider" type="xsd:string" />
219-
<xsd:attribute name="directory" type="xsd:string" />
220219
<xsd:attribute name="clearer" type="xsd:string" />
221220
</xsd:complexType>
222221
</xsd:schema>

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ protected static function getBundleDefaultConfig()
265265
'base_urls' => array(),
266266
'packages' => array(),
267267
),
268+
'cache' => array(
269+
'pools' => array(),
270+
),
268271
);
269272
}
270273
}

‎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
@@ -8,7 +8,7 @@ services:
88
calls:
99
- [connect, [127.0.0.1]]
1010

11-
cache.adapter.default:
11+
cache.adapter.shared:
1212
abstract: true
1313
parent: cache.adapter.redis
1414
tags:

‎src/Symfony/Bundle/FrameworkBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"require": {
1919
"php": ">=5.5.9",
2020
"symfony/asset": "~2.8|~3.0",
21+
"symfony/cache": "~3.1",
2122
"symfony/class-loader": "~2.8|~3.0",
2223
"symfony/dependency-injection": "~3.1",
2324
"symfony/config": "~2.8|~3.0",
@@ -38,7 +39,6 @@
3839
},
3940
"require-dev": {
4041
"symfony/browser-kit": "~2.8|~3.0",
41-
"symfony/cache": "~3.1",
4242
"symfony/console": "~2.8|~3.0",
4343
"symfony/css-selector": "~2.8|~3.0",
4444
"symfony/dom-crawler": "~2.8|~3.0",

‎src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public static function setupBeforeClass()
3737
$e = error_get_last();
3838
self::markTestSkipped($e['message']);
3939
}
40-
self::$redis->select(1993);
4140
}
4241

4342
public static function tearDownAfterClass()

‎src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\DependencyInjection\DefinitionDecorator;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
18-
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
1918

2019
/**
2120
* This replaces all DefinitionDecorator instances with their equivalent fully
@@ -97,12 +96,11 @@ private function resolveArguments(ContainerBuilder $container, array $arguments,
9796
*/
9897
private function resolveDefinition(ContainerBuilder $container, DefinitionDecorator $definition)
9998
{
100-
try {
101-
$parentDef = $container->findDefinition($parent = $definition->getParent());
102-
} catch (ServiceNotFoundException $e) {
99+
if (!$container->has($parent = $definition->getParent())) {
103100
throw new RuntimeException(sprintf('The parent definition "%s" defined for definition "%s" does not exist.', $parent, $this->currentId));
104101
}
105102

103+
$parentDef = $container->findDefinition($parent);
106104
if ($parentDef instanceof DefinitionDecorator) {
107105
$id = $this->currentId;
108106
$this->currentId = $parent;

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,20 @@ public function testProcessMergeAutowiringTypes()
309309
$this->assertEquals(array('Foo', 'Bar'), $def->getAutowiringTypes());
310310
}
311311

312+
public function testProcessResolvesAliases()
313+
{
314+
$container = new ContainerBuilder();
315+
316+
$container->register('parent', 'ParentClass');
317+
$container->setAlias('parent_alias', 'parent');
318+
$container->setDefinition('child', new DefinitionDecorator('parent_alias'));
319+
320+
$this->process($container);
321+
322+
$def = $container->getDefinition('child');
323+
$this->assertSame('ParentClass', $def->getClass());
324+
}
325+
312326
protected function process(ContainerBuilder $container)
313327
{
314328
$pass = new ResolveDefinitionTemplatesPass();

0 commit comments

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