8000 [FrameworkBundle] add `kernel.locale_aware` tag to `LocaleSwitcher` · jeremyFreeAgent/symfony@1661c7e · GitHub
[go: up one dir, main page]

Skip to content

Commit 1661c7e

Browse files
committed
[FrameworkBundle] add kernel.locale_aware tag to LocaleSwitcher
1 parent d73ab82 commit 1661c7e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,11 @@
168168
->set('translation.locale_switcher', LocaleSwitcher::class)
169169
->args([
170170
param('kernel.default_locale'),
171-
tagged_iterator('kernel.locale_aware'),
171+
tagged_iterator('kernel.locale_aware', exclude: 'translation.locale_switcher'),
172172
service('router.request_context')->ignoreOnInvalid(),
173173
])
174174
->tag('kernel.reset', ['method' => 'reset'])
175+
->tag('kernel.locale_aware')
175176
->alias(LocaleAwareInterface::class, 'translation.locale_switcher')
176177
->alias(LocaleSwitcher::class, 'translation.locale_switcher')
177178
;

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use Symfony\Component\DependencyInjection\ChildDefinition;
3838
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
3939
use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass;
40+
use Symfony\Component\DependencyInjection\Compiler\ResolveTaggedIteratorArgumentPass;
4041
use Symfony\Component\DependencyInjection\ContainerBuilder;
4142
use Symfony\Component\DependencyInjection\ContainerInterface;
4243
use Symfony\Component\DependencyInjection\Definition;
@@ -2057,7 +2058,9 @@ public function testLocaleSwitcherServiceRegistered()
20572058
$this->markTestSkipped('LocaleSwitcher not available.');
20582059
}
20592060

2060-
$container = $this->createContainerFromFile('full');
2061+
$container = $this->createContainerFromFile('full', compile: false);
2062+
$container->addCompilerPass(new ResolveTaggedIteratorArgumentPass());
2063+
$container->compile();
20612064

20622065
$this->assertTrue($container->has('translation.locale_switcher'));
20632066

@@ -2067,6 +2070,10 @@ public function testLocaleSwitcherServiceRegistered()
20672070
$this->assertInstanceOf(TaggedIteratorArgument::class, $switcherDef->getArgument(1));
20682071
$this->assertSame('kernel.locale_aware', $switcherDef->getArgument(1)->getTag());
20692072
$this->assertEquals(new Reference('router.request_context', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE), $switcherDef->getArgument(2));
2073+
2074+
$localeAwareServices = array_map(fn (Reference $r) => (string) $r, $switcherDef->getArgument(1)->getValues());
2075+
2076+
$this->assertNotContains('translation.locale_switcher', $localeAwareServices);
20702077
}
20712078

20722079
public function testHtmlSanitizer()

0 commit comments

Comments
 (0)
0