8000 bug #30261 [Translation] restore compatibility with FrameworkBundle 4… · enumag/symfony@f02c97f · GitHub
[go: up one dir, main page]

Skip to content

Commit f02c97f

Browse files
bug symfony#30261 [Translation] restore compatibility with FrameworkBundle 4.2 (xabbuh)
This PR was merged into the 4.3-dev branch. Discussion ---------- [Translation] restore compatibility with FrameworkBundle 4.2 | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#30260 | License | MIT | Doc PR | Commits ------- 45dde5d restore compatibility with FrameworkBundle 4.2
2 parents 3b8fa12 + 45dde5d commit f02c97f

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,18 @@ public function process(ContainerBuilder $container)
7272
if ($container->hasDefinition($this->debugCommandServiceId)) {
7373
$definition = $container->getDefinition($this->debugCommandServiceId);
7474
$definition->replaceArgument(4, $container->getParameter('twig.default_path'));
75-
$definition->replaceArgument(6, $paths);
75+
76+
if (\count($definition->getArguments()) > 6) {
77+
$definition->replaceArgument(6, $paths);
78+
}
7679
}
7780
if ($container->hasDefinition($this->updateCommandServiceId)) {
7881
$definition = $container->getDefinition($this->updateCommandServiceId);
7982
$definition->replaceArgument(5, $container->getParameter('twig.default_path'));
80-
$definition->replaceArgument(7, $paths);
83+
84+
if (\count($definition->getArguments()) > 7) {
85+
$definition->replaceArgument(7, $paths);
86+
}
8187
}
8288
}
8389
}

src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationPassTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,41 @@ public function testValidCommandsViewPathsArgument()
8282
$this->assertSame($expectedViewPaths, $debugCommand->getArgument(6));
8383
$this->assertSame($expectedViewPaths, $updateCommand->getArgument(7));
8484
}
85+
86+
public function testCommandsViewPathsArgumentsAreIgnoredWithOldServiceDefinitions()
87+
{
88+
$container = new ContainerBuilder();
89+
$container->register('translator.default')
90+
->setArguments([null, null, null, null])
91+
;
92+
$debugCommand = $container->register('console.command.translation_debug')
93+
->setArguments([
94+
new Reference('translator'),
95+
new Reference('translation.reader'),
96+
new Reference('translation.extractor'),
97+
'%translator.default_path%',
98+
null,
99+
])
100+
;
101+
$updateCommand = $container->register('console.command.translation_update')
102+
->setArguments([
103+
new Reference('translation.writer'),
104+
new Reference('translation.reader'),
105+
new Reference('translation.extractor'),
106+
'%kernel.default_locale%',
107+
'%translator.default_path%',
108+
null,
109+
])
110+
;
111+
$container->register('twig.template_iterator')
112+
->setArguments([null, null, ['other/templates' => null, 'tpl' => 'App']])
113+
;
114+
$container->setParameter('twig.default_path', 'templates');
115+
116+
$pass = new TranslatorPass('translator.default');
117+
$pass->process($container);
118+
119+
$this->assertSame('templates', $debugCommand->getArgument(4));
120+
$this->assertSame('templates', $updateCommand->getArgument(5));
121+
}
85122
}

0 commit comments

Comments
 (0)
0