8000 bug #48534 [FrameworkBundle] add `kernel.locale_aware` tag to `Locale… · jeremyFreeAgent/symfony@fc10553 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit fc10553

Browse files
committed
bug symfony#48534 [FrameworkBundle] add kernel.locale_aware tag to LocaleSwitcher (kbond)
This PR was merged into the 6.1 branch. Discussion ---------- [FrameworkBundle] add `kernel.locale_aware` tag to `LocaleSwitcher` | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix symfony#48499 | License | MIT | Doc PR | n/a This adds `kernel.locale_aware` to the `LocalSwitcher` service so that when autowiring `LocaleAwareInterface` (which is an alias for `LocaleSwitcher`), it has the current locale. Commits ------- 1661c7e [FrameworkBundle] add `kernel.locale_aware` tag to `LocaleSwitcher`
2 parents d73ab82 + 1661c7e commit fc10553

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
->ta 8000 g('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