|
12 | 12 | namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
|
13 | 13 |
|
14 | 14 | use Doctrine\Common\Annotations\Reader;
|
15 |
| -use Symfony\Component\Cache\Adapter\ApcuAdapter; |
16 |
| -use Symfony\Component\Cache\Adapter\DoctrineAdapter; |
17 |
| -use Symfony\Component\Cache\Adapter\FilesystemAdapter; |
18 | 15 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
19 | 16 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
20 | 17 | use Symfony\Component\DependencyInjection\Definition;
|
@@ -1023,43 +1020,24 @@ private function registerPropertyInfoConfiguration(array $config, ContainerBuild
|
1023 | 1020 | }
|
1024 | 1021 | }
|
1025 | 1022 |
|
1026 |
| - private function registerCacheConfiguration(array $config, ContainerBuilder $container) |
| 1023 | + private function registerCacheConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) |
1027 | 1024 | {
|
1028 |
| - foreach ($config['adapters'] as $name => $adapter) { |
1029 |
| - $class = null; |
1030 |
| - $arguments = array(); |
1031 |
| - $namespaceArgumentIndex = null; |
1032 |
| - |
1033 |
| - switch ($adapter['type']) { |
1034 |
| - case 'apcu': |
1035 |
| - $class = ApcuAdapter::class; |
1036 |
| - $arguments[] = null; |
1037 |
| - $arguments[] = isset($adapter['options']['default_lifetime']) ? $adapter['options']['default_lifetime'] : 0; |
1038 |
| - $namespaceArgumentIndex = 0; |
1039 |
| - break; |
1040 |
| - case 'doctrine': |
1041 |
| - $class = DoctrineAdapter::class; |
1042 |
| - $arguments[] = isset($adapter['options']['cache_provider_service']) ? new Reference($adapter['options']['cache_provider_service']) : null; |
1043 |
| - $arguments[] = isset($adapter['options']['default_lifetime']) ? $adapter['options']['default_lifetime'] : null; |
1044 |
| - break; |
1045 |
| - case 'filesystem': |
1046 |
| - $class = FilesystemAdapter::class; |
1047 |
| - $arguments[] = isset($adapter['options']['directory']) ? $adapter['options']['directory'] : null; |
1048 |
| - $arguments[] = isset($adapter['options']['default_lifetime']) ? $adapter['options']['default_lifetime'] : null; |
1049 |
| - break; |
1050 |
| - } |
| 1025 | + if (!empty($config['pool'])) { |
| 1026 | + $loader->load('cache_adapters.xml'); |
| 1027 | + } |
1051 | 1028 |
|
1052 |
| - $tagAttributes = array('id' => $name); |
| 1029 | + foreach ($config['pool'] as $name => $poolConfig) { |
| 1030 | + $poolDefinition = new DefinitionDecorator('cache.adapter.'.$poolConfig['type']); |
| 1031 | + $poolDefinition->replaceArgument(1, $poolConfig['default_lifetime']); |
1053 | 1032 |
|
1054 |
| - if (null !== $namespaceArgumentIndex) { |
1055 |
| - $tagAttributes['namespace-arg-index'] = $namespaceArgumentIndex; |
| 1033 | + if ('doctrine' === $poolConfig['type'] || 'psr6' === $poolConfig['type']) { |
| 1034 | + $poolDefinition->replaceArgument(0, new Reference($poolConfig['cache_provider_service'])); |
| 1035 | + } elseif ('filesystem' === $poolConfig['type'] && isset($poolConfig['directory'][0])) { |
| 1036 | + $poolDefinition->replaceArgument(0, $poolConfig['directory']); |
1056 | 1037 | }
|
1057 | 1038 |
|
1058 |
| - $adapterDefinition = new Definition($class); |
1059 |
| - $adapterDefinition->setArguments($arguments); |
1060 |
| - $adapterDefinition->setAbstract(true); |
1061 |
| - $adapterDefinition->addTag('cache.adapter', $tagAttributes); |
1062 |
| - $container->setDefinition('cache.adapter.'.$name, $adapterDefinition); |
| 1039 | + $poolDefinition->addTag('cache.pool'); |
| 1040 | + $container->setDefinition('cache.pool.'.$name, $poolDefinition); |
1063 | 1041 | }
|
1064 | 1042 | }
|
1065 | 1043 |
|
|
0 commit comments