bug #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 | #30260
| License       | MIT
| Doc PR        |

Commits
-------

45dde5d00c restore compatibility with FrameworkBundle 4.2
This commit is contained in:
Nicolas Grekas 2019-02-16 19:46:38 +01:00
commit f02c97f857
2 changed files with 45 additions and 2 deletions

View File

@ -72,12 +72,18 @@ class TranslatorPass implements CompilerPassInterface
if ($container->hasDefinition($this->debugCommandServiceId)) {
$definition = $container->getDefinition($this->debugCommandServiceId);
$definition->replaceArgument(4, $container->getParameter('twig.default_path'));
$definition->replaceArgument(6, $paths);
if (\count($definition->getArguments()) > 6) {
$definition->replaceArgument(6, $paths);
}
}
if ($container->hasDefinition($this->updateCommandServiceId)) {
$definition = $container->getDefinition($this->updateCommandServiceId);
$definition->replaceArgument(5, $container->getParameter('twig.default_path'));
$definition->replaceArgument(7, $paths);
if (\count($definition->getArguments()) > 7) {
$definition->replaceArgument(7, $paths);
}
}
}
}

View File

@ -82,4 +82,41 @@ class TranslationPassTest extends TestCase
$this->assertSame($expectedViewPaths, $debugCommand->getArgument(6));
$this->assertSame($expectedViewPaths, $updateCommand->getArgument(7));
}
public function testCommandsViewPathsArgumentsAreIgnoredWithOldServiceDefinitions()
{
$container = new ContainerBuilder();
$container->register('translator.default')
->setArguments([null, null, null, null])
;
$debugCommand = $container->register('console.command.translation_debug')
->setArguments([
new Reference('translator'),
new Reference('translation.reader'),
new Reference('translation.extractor'),
'%translator.default_path%',
null,
])
;
$updateCommand = $container->register('console.command.translation_update')
->setArguments([
new Reference('translation.writer'),
new Reference('translation.reader'),
new Reference('translation.extractor'),
'%kernel.default_locale%',
'%translator.default_path%',
null,
])
;
$container->register('twig.template_iterator')
->setArguments([null, null, ['other/templates' => null, 'tpl' => 'App']])
;
$container->setParameter('twig.default_path', 'templates');
$pass = new TranslatorPass('translator.default');
$pass->process($container);
$this->assertSame('templates', $debugCommand->getArgument(4));
$this->assertSame('templates', $updateCommand->getArgument(5));
}
}