File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ public function process(ContainerBuilder $container)
44
44
$ definition ->setMethodCalls ($ this ->processArguments ($ definition ->getMethodCalls ()));
45
45
$ definition ->setProperties ($ this ->processArguments ($ definition ->getProperties ()));
46
46
$ definition ->setFactory ($ this ->processFactory ($ definition ->getFactory ()));
47
+
48
+ if (null !== $ factoryService = $ definition ->getFactoryService (false )) {
49
+ $ definition ->setFactoryService ($ this ->processFactoryService ($ factoryService ));
50
+ }
47
51
}
48
52
49
53
foreach ($ container ->getAliases () as $ id => $ alias ) {
@@ -78,6 +82,15 @@ private function processArguments(array $arguments)
78
82
return $ arguments ;
79
83
}
80
84
85
+ private function processFactoryService ($ factoryService )
86
+ {
87
+ if (null === $ factoryService ) {
88
+ return ;
89
+ }
90
+
91
+ return $ this ->getDefinitionId ($ factoryService );
92
+ }
93
+
81
94
private function processFactory ($ factory )
82
95
{
83
96
if (null === $ factory || !is_array ($ factory ) || !$ factory [0 ] instanceof Reference) {
Original file line number Diff line number Diff line change @@ -82,6 +82,24 @@ public function testResolveFactory()
82
82
$ this ->assertSame ('Factory ' , (string ) $ resolvedBarFactory [0 ]);
83
83
}
84
84
85
+ /**
86
+ * @group legacy
87
+ */
88
+ public function testResolveFactoryService ()
89
+ {
90
+ $ container = new ContainerBuilder ();
91
+ $ container ->register ('factory ' , 'Factory ' );
92
+ $ container ->setAlias ('factory_alias ' , new Alias ('factory ' ));
93
+ $ foo = new Definition ();
94
+ $ foo ->setFactoryService ('factory_alias ' );
95
+ $ foo ->setFactoryMethod ('createFoo ' );
96
+ $ container ->setDefinition ('foo ' , $ foo );
97
+
98
+ $ this ->process ($ container );
99
+
100
+ $ this ->assertSame ('factory ' , $ foo ->getFactoryService ());
101
+ }
102
+
85
103
protected function process (ContainerBuilder $ container )
86
104
{
87
105
$ pass = new ResolveReferencesToAliasesPass ();
You can’t perform that action at this time.
0 commit comments