Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a1c77e7

Browse filesBrowse files
committed
bug #23370 [FrameworkBundle] Wire inner translator (ogizanagi)
This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle] Wire inner translator | Q | A | ------------- | --- | Branch? | 3.4 <!-- see comment below --> | Bug fix? | yes | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #23293 (comment) | License | MIT | Doc PR | N/A Commits ------- a32cae5 [FrameworkBundle] Wire inner translator
2 parents ddc4b20 + a32cae5 commit a1c77e7
Copy full SHA for a1c77e7

File tree

Expand file treeCollapse file tree

2 files changed

+26
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+26
-2
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/LoggingTranslatorPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/LoggingTranslatorPass.php
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\DependencyInjection\ContainerBuilder;
1515
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1616
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
17-
use Symfony\Component\DependencyInjection\Reference;
1817
use Symfony\Component\Translation\TranslatorInterface;
1918
use Symfony\Component\Translation\TranslatorBagInterface;
2019

@@ -39,7 +38,16 @@ public function process(ContainerBuilder $container)
3938
}
4039
if ($r->isSubclassOf(TranslatorInterface::class) && $r->isSubclassOf(TranslatorBagInterface::class)) {
4140
$container->getDefinition('translator.logging')->setDecoratedService('translator');
42-
$container->getDefinition('translation.warmer')->replaceArgument(0, new Reference('translator.logging.inner'));
41+
$warmer = $container->getDefinition('translation.warmer');
42+
$subscriberAttributes = $warmer->getTag('container.service_subscriber');
43+
$warmer->clearTag('container.service_subscriber');
44+
45+
foreach ($subscriberAttributes as $k => $v) {
46+
if ((!isset($v['id']) || 'translator' !== $v['id']) && (!isset($v['key']) || 'translator' !== $v['key'])) {
47+
$warmer->addTag('container.service_subscriber', $v);
48+
}
49+
}
50+
$warmer->addTag('container.service_subscriber', array('key' => 'translator', 'id' => 'translator.logging.inner'));
4351
}
4452
}
4553
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ public function testProcess()
6060
->with('Symfony\Bundle\FrameworkBundle\Translation\Translator')
6161
->will($this->returnValue(new \ReflectionClass('Symfony\Bundle\FrameworkBundle\Translation\Translator')));
6262

63+
$definition->expects($this->once())
64+
->method('getTag')
65+
->with('container.service_subscriber')
66+
->willReturn(array(array('id' => 'translator'), array('id' => 'foo')));
67+
68+
$definition->expects($this->once())
69+
->method('clearTag')
70+
->with('container.service_subscriber');
71+
72+
$definition->expects($this->any())
73+
->method('addTag')
74+
->withConsecutive(
75+
array('container.service_subscriber', array('id' => 'foo')),
76+
array('container.service_subscriber', array('key' => 'translator', 'id' => 'translator.logging.inner'))
77+
);
78+
6379
$pass = new LoggingTranslatorPass();
6480
$pass->process($container);
6581
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.