File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed
DependencyInjection/Compiler
Tests/DependencyInjection/Compiler Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public function process(ContainerBuilder $container)
63
63
}
64
64
$ definition ->setMethodCalls ($ calls );
65
65
66
- if (! $ definition instanceof ChildDefinition && \method_exists ($ definition , 'getBindings ' )) {
66
+ if (\method_exists ($ definition , 'getBindings ' )) {
67
67
$ binding = new BoundArgument (new Reference ($ loggerId ));
68
68
69
69
// Mark the binding as used already, to avoid reporting it as unused if the service does not use a
Original file line number Diff line number Diff line change @@ -82,6 +82,28 @@ public function testAutowiredLoggerArgumentsAreReplacedWithChannelLogger()
82
82
$ this ->assertEquals ('monolog.logger.test ' , (string ) $ dummyService ->getArgument (0 ));
83
83
}
84
84
85
+ public function testAutowiredLoggerArgumentsAreReplacedWithChannelLoggerWhenAutoconfigured ()
86
+ {
87
+ if (!\method_exists ('Symfony\Component\DependencyInjection\Definition ' , 'getBindings ' )) {
88
+ $ this ->markTestSkipped ('Need DependencyInjection 3.4+ to autowire channel logger. ' );
89
+ }
90
+
91
+ $ container = $ this ->getFunctionalContainer ();
92
+
93
+ $ container ->registerForAutoconfiguration ('Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Compiler\DummyService ' )
94
+ ->setProperty ('fake ' , 'dummy ' );
95
+
96
+ $ container ->register ('dummy_service ' , 'Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Compiler\DummyService ' )
97
+ ->setAutowired (true )
98
+ ->setAutoconfigured (true )
99
+ ->setPublic (true )
100
+ ->addTag ('monolog.logger ' , array ('channel ' => 'test ' ));
101
+
102
+ $ container ->compile ();
103
+
104
+ $ this ->assertEquals ('monolog.logger.test ' , (string ) $ container ->getDefinition ('dummy_service ' )->getArgument (0 ));
105
+ }
106
+
85
107
public function testAutowiredLoggerArgumentsAreNotReplacedWithChannelLoggerIfLoggerArgumentIsConfiguredExplicitly ()
86
108
{
87
109
if (!\method_exists ('Symfony\Component\DependencyInjection\Definition ' , 'getBindings ' )) {
Original file line number Diff line number Diff line change 18
18
"require" : {
19
19
"php" : " >=5.6" ,
20
20
"symfony/monolog-bridge" : " ~2.7|~3.3|~4.0" ,
21
- "symfony/dependency-injection" : " ~2.7|~3.3|~ 4.0" ,
21
+ "symfony/dependency-injection" : " ~2.7|~3.4.10|^ 4.0.10 " ,
22
22
"symfony/config" : " ~2.7|~3.3|~4.0" ,
23
23
"symfony/http-kernel" : " ~2.7|~3.3|~4.0" ,
24
24
"monolog/monolog" : " ~1.22"
You can’t perform that action at this time.
0 commit comments