[FrameworkBundle] fix named autowiring aliases for TagAwareCacheInterface

This commit is contained in:
Nicolas Grekas 2019-05-22 21:16:22 +02:00
parent 1cd99eaaa8
commit d9082c2ae4

View File

@ -117,6 +117,7 @@ use Symfony\Component\Workflow\WorkflowInterface;
use Symfony\Component\Yaml\Command\LintCommand as BaseYamlLintCommand;
use Symfony\Component\Yaml\Yaml;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\TagAwareCacheInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\Service\ResetInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
@ -1819,10 +1820,6 @@ class FrameworkExtension extends Extension
$pool['adapter'] = '.'.$pool['adapter'].'.inner';
}
$definition = new ChildDefinition($pool['adapter']);
if (!\in_array($name, ['cache.app', 'cache.system'], true)) {
$container->registerAliasForArgument($name, CacheInterface::class);
$container->registerAliasForArgument($name, CacheItemPoolInterface::class);
}
if ($pool['tags']) {
if ($config['pools'][$pool['tags']]['tags'] ?? false) {
@ -1837,7 +1834,21 @@ class FrameworkExtension extends Extension
$pool['name'] = $name;
$pool['public'] = false;
$name = '.'.$name.'.inner';
if (!\in_array($pool['name'], ['cache.app', 'cache.system'], true)) {
$container->registerAliasForArgument($pool['name'], TagAwareCacheInterface::class);
$container->registerAliasForArgument($name, CacheInterface::class, $pool['name']);
$container->registerAliasForArgument($name, CacheItemPoolInterface::class, $pool['name']);
}
} elseif (!\in_array($name, ['cache.app', 'cache.system'], true)) {
$container->register('.'.$name.'.taggable', TagAwareAdapter::class)
->addArgument(new Reference($name))
;
$container->registerAliasForArgument('.'.$name.'.taggable', TagAwareCacheInterface::class, $name);
$container->registerAliasForArgument($name, CacheInterface::class);
$container->registerAliasForArgument($name, CacheItemPoolInterface::class);
}
$definition->setPublic($pool['public']);
unset($pool['adapter'], $pool['public'], $pool['tags']);