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)
6363 }
6464 $ definition ->setMethodCalls ($ calls );
6565
66- if (! $ definition instanceof ChildDefinition && \method_exists ($ definition , 'getBindings ' )) {
66+ if (\method_exists ($ definition , 'getBindings ' )) {
6767 $ binding = new BoundArgument (new Reference ($ loggerId ));
6868
6969 // 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()
8282 $ this ->assertEquals ('monolog.logger.test ' , (string ) $ dummyService ->getArgument (0 ));
8383 }
8484
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+
85107 public function testAutowiredLoggerArgumentsAreNotReplacedWithChannelLoggerIfLoggerArgumentIsConfiguredExplicitly ()
86108 {
87109 if (!\method_exists ('Symfony\Component\DependencyInjection\Definition ' , 'getBindings ' )) {
Original file line number Diff line number Diff line change 1818 "require" : {
1919 "php" : " >=5.6" ,
2020 "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 " ,
2222 "symfony/config" : " ~2.7|~3.3|~4.0" ,
2323 "symfony/http-kernel" : " ~2.7|~3.3|~4.0" ,
2424 "monolog/monolog" : " ~1.22"
You can’t perform that action at this time.
0 commit comments