File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
DependencyInjection/Compiler
Tests/DependencyInjection/Compiler Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1111
1212namespace Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler ;
1313
14+ use Symfony \Component \DependencyInjection \Argument \ServiceClosureArgument ;
1415use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
1516use Symfony \Component \DependencyInjection \ContainerBuilder ;
1617use Symfony \Component \DependencyInjection \Reference ;
@@ -38,6 +39,16 @@ public function process(ContainerBuilder $container)
3839 }
3940 }
4041
42+ foreach ($ container ->getAliases () as $ id => $ target ) {
43+ while ($ container ->hasAlias ($ target = (string ) $ target )) {
44+ $ target = $ container ->getAlias ($ target );
45+ }
46+
47+ if ($ definitions [$ target ]->hasTag ('container.private ' )) {
48+ $ privateServices [$ id ] = new ServiceClosureArgument (new Reference ($ target ));
49+ }
50+ }
51+
4152 $ privateContainer ->replaceArgument (0 , $ privateServices );
4253 }
4354}
Original file line number Diff line number Diff line change @@ -43,6 +43,13 @@ public function testProcess()
4343 ->setPublic (true )
4444 ->addTag ('container.private ' , ['package ' => 'foo/bar ' , 'version ' => '1.42 ' ])
4545 ;
46+ $ container ->register ('Test\soon_private_service_decorated ' )
47+ ->setPublic (true )
48+ ->addTag ('container.private ' , ['package ' => 'foo/bar ' , 'version ' => '1.42 ' ])
49+ ;
50+ $ container ->register ('Test\soon_private_service_decorator ' )
51+ ->setDecoratedService ('Test\soon_private_service_decorated ' )
52+ ->setArguments (['Test\soon_private_service_decorator.inner ' ]);
4653
4754 $ container ->register ('Test\private_used_shared_service ' );
4855 $ container ->register ('Test\private_unused_shared_service ' );
@@ -55,6 +62,8 @@ public function testProcess()
5562 'Test\private_used_shared_service ' => new ServiceClosureArgument (new Reference ('Test\private_used_shared_service ' )),
5663 'Test\private_used_non_shared_service ' => new ServiceClosureArgument (new Reference ('Test\private_used_non_shared_service ' )),
5764 'Test\soon_private_service ' => new ServiceClosureArgument (new Reference ('.container.private.Test\soon_private_service ' )),
65+ 'Test\soon_private_service_decorator ' => new ServiceClosureArgument (new Reference ('.container.private.Test\soon_private_service_decorated ' )),
66+ 'Test\soon_private_service_decorated ' => new ServiceClosureArgument (new Reference ('.container.private.Test\soon_private_service_decorated ' )),
5867 ];
5968
6069 $ privateServices = $ container ->getDefinition ('test.private_services_locator ' )->getArgument (0 );
You can’t perform that action at this time.
0 commit comments