File tree 2 files changed +20
-0
lines changed
src/Symfony/Bundle/FrameworkBundle
DependencyInjection/Compiler
Tests/DependencyInjection/Compiler
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler ;
13
13
14
+ use Symfony \Component \DependencyInjection \Argument \ServiceClosureArgument ;
14
15
use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
15
16
use Symfony \Component \DependencyInjection \ContainerBuilder ;
16
17
use Symfony \Component \DependencyInjection \Reference ;
@@ -38,6 +39,16 @@ public function process(ContainerBuilder $container)
38
39
}
39
40
}
40
41
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
+
41
52
$ privateContainer ->replaceArgument (0 , $ privateServices );
42
53
}
43
54
}
Original file line number Diff line number Diff line change @@ -43,6 +43,13 @@ public function testProcess()
43
43
->setPublic (true )
44
44
->addTag ('container.private ' , ['package ' => 'foo/bar ' , 'version ' => '1.42 ' ])
45
45
;
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 ' ]);
46
53
47
54
$ container ->register ('Test\private_used_shared_service ' );
48
55
$ container ->register ('Test\private_unused_shared_service ' );
@@ -55,6 +62,8 @@ public function testProcess()
55
62
'Test\private_used_shared_service ' => new ServiceClosureArgument (new Reference ('Test\private_used_shared_service ' )),
56
63
'Test\private_used_non_shared_service ' => new ServiceClosureArgument (new Reference ('Test\private_used_non_shared_service ' )),
57
64
'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 ' )),
58
67
];
59
68
60
69
$ privateServices = $ container ->getDefinition ('test.private_services_locator ' )->getArgument (0 );
You can’t perform that action at this time.
0 commit comments