bug #31591 [FrameworkBundle] fix named autowiring aliases for TagAwareCacheInterface (nicolas-grekas)
This PR was merged into the 4.3 branch.
Discussion
----------
[FrameworkBundle] fix named autowiring aliases for TagAwareCacheInterface
| Q | A
| ------------- | ---
| Branch? | 4.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Doing a demo today, I realized that named autowiring aliases are missing for `TagAwareCacheInterface`, and that existing ones point to the wrong service. Here is the fix.
Commits
-------
d9082c2ae4
[FrameworkBundle] fix named autowiring aliases for TagAwareCacheInterface
This commit is contained in:
commit
77153b0ca2
@ -117,6 +117,7 @@ use Symfony\Component\Workflow\WorkflowInterface;
|
|||||||
use Symfony\Component\Yaml\Command\LintCommand as BaseYamlLintCommand;
|
use Symfony\Component\Yaml\Command\LintCommand as BaseYamlLintCommand;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
use Symfony\Contracts\Cache\CacheInterface;
|
use Symfony\Contracts\Cache\CacheInterface;
|
||||||
|
use Symfony\Contracts\Cache\TagAwareCacheInterface;
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
use Symfony\Contracts\Service\ResetInterface;
|
use Symfony\Contracts\Service\ResetInterface;
|
||||||
use Symfony\Contracts\Service\ServiceSubscriberInterface;
|
use Symfony\Contracts\Service\ServiceSubscriberInterface;
|
||||||
@ -1819,10 +1820,6 @@ class FrameworkExtension extends Extension
|
|||||||
$pool['adapter'] = '.'.$pool['adapter'].'.inner';
|
$pool['adapter'] = '.'.$pool['adapter'].'.inner';
|
||||||
}
|
}
|
||||||
$definition = new ChildDefinition($pool['adapter']);
|
$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 ($pool['tags']) {
|
||||||
if ($config['pools'][$pool['tags']]['tags'] ?? false) {
|
if ($config['pools'][$pool['tags']]['tags'] ?? false) {
|
||||||
@ -1837,7 +1834,21 @@ class FrameworkExtension extends Extension
|
|||||||
$pool['name'] = $name;
|
$pool['name'] = $name;
|
||||||
$pool['public'] = false;
|
$pool['public'] = false;
|
||||||
$name = '.'.$name.'.inner';
|
$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']);
|
$definition->setPublic($pool['public']);
|
||||||
unset($pool['adapter'], $pool['public'], $pool['tags']);
|
unset($pool['adapter'], $pool['public'], $pool['tags']);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user