File tree 2 files changed +26
-2
lines changed
src/Symfony/Bundle/FrameworkBundle
DependencyInjection/Compiler
Tests/DependencyInjection/Compiler
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 14
14
use Symfony \Component \DependencyInjection \ContainerBuilder ;
15
15
use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
16
16
use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
17
- use Symfony \Component \DependencyInjection \Reference ;
18
17
use Symfony \Component \Translation \TranslatorInterface ;
19
18
use Symfony \Component \Translation \TranslatorBagInterface ;
20
19
@@ -39,7 +38,16 @@ public function process(ContainerBuilder $container)
39
38
}
40
39
if ($ r ->isSubclassOf (TranslatorInterface::class) && $ r ->isSubclassOf (TranslatorBagInterface::class)) {
41
40
$ 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 ' ));
43
51
}
44
52
}
45
53
}
Original file line number Diff line number Diff line change @@ -60,6 +60,22 @@ public function testProcess()
60
60
->with ('Symfony\Bundle\FrameworkBundle\Translation\Translator ' )
61
61
->will ($ this ->returnValue (new \ReflectionClass ('Symfony\Bundle\FrameworkBundle\Translation\Translator ' )));
62
62
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
+
63
79
$ pass = new LoggingTranslatorPass ();
64
80
$ pass ->process ($ container );
65
81
}
You can’t perform that action at this time.
0 commit comments