Skip to content

Commit decd87b

Browse files
[FrameworkBundle] fix named autowiring aliases for TagAwareCacheInterface
1 parent 1cd99ea commit decd87b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
3434
use Symfony\Component\Cache\Marshaller\MarshallerInterface;
3535
use Symfony\Component\Cache\ResettableInterface;
36+
use Symfony\Component\Cache\TagAwareCacheInterface;
3637
use Symfony\Component\Config\FileLocator;
3738
use Symfony\Component\Config\Loader\LoaderInterface;
3839
use Symfony\Component\Config\Resource\DirectoryResource;
@@ -1819,10 +1820,6 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
18191820
$pool['adapter'] = '.'.$pool['adapter'].'.inner';
18201821
}
18211822
$definition = new ChildDefinition($pool['adapter']);
1822-
if (!\in_array($name, ['cache.app', 'cache.system'], true)) {
1823-
$container->registerAliasForArgument($name, CacheInterface::class);
1824-
$container->registerAliasForArgument($name, CacheItemPoolInterface::class);
1825-
}
18261823

18271824
if ($pool['tags']) {
18281825
if ($config['pools'][$pool['tags']]['tags'] ?? false) {
@@ -1837,7 +1834,21 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
18371834
$pool['name'] = $name;
18381835
$pool['public'] = false;
18391836
$name = '.'.$name.'.inner';
1837+
1838+
if (!\in_array($pool['name'], ['cache.app', 'cache.system'], true)) {
1839+
$container->registerAliasForArgument($pool['name'], TagAwareCacheInterface::class);
1840+
$container->registerAliasForArgument($name, CacheInterface::class, $pool['name']);
1841+
$container->registerAliasForArgument($name, CacheItemPoolInterface::class, $pool['name']);
1842+
}
1843+
} elseif (!\in_array($name, ['cache.app', 'cache.system'], true)) {
1844+
$container->register('.'.$name.'.taggable', TagAwareAdapter::class)
1845+
->addArgument(new Reference($name))
1846+
;
1847+
$container->registerAliasForArgument('.'.$name.'.taggable', TagAwareCacheInterface::class, $name);
1848+
$container->registerAliasForArgument($name, CacheInterface::class);
1849+
$container->registerAliasForArgument($name, CacheItemPoolInterface::class);
18401850
}
1851+
18411852
$definition->setPublic($pool['public']);
18421853
unset($pool['adapter'], $pool['public'], $pool['tags']);
18431854

0 commit comments

Comments
 (0)