File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
DependencyInjection/Compiler
Tests/DependencyInjection/Compiler Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1414use Symfony \Component \DependencyInjection \ContainerBuilder ;
1515use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
1616use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
17- use Symfony \Component \DependencyInjection \Reference ;
1817use Symfony \Component \Translation \TranslatorInterface ;
1918use 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 }
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments