File tree 2 files changed +23
-4
lines changed
2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,20 @@ public function has($id) {
225
225
return isset ($ this ->services [$ id ]) || isset ($ this ->serviceDefinitions [$ id ]);
226
226
}
227
227
228
+ /**
229
+ * {@inheritdoc}
230
+ */
231
+ public function createInstance ($ plugin_id , $ service_definition ) {
232
+ $ temporary_name = 'plugin_ ' . $ plugin_id ;
233
+ $ this ->serviceDefinitions [$ temporary_name ] = $ service_definition ;
234
+
235
+ $ plugin = $ this ->get ($ temporary_name );
236
+ unset($ this ->serviceDefinitions [$ temporary_name ]);
237
+ unset($ this ->services [$ temporary_name ]);
238
+
239
+ return $ plugin ;
240
+ }
241
+
228
242
/**
229
243
* {@inheritdoc}
230
244
*/
Original file line number Diff line number Diff line change @@ -59,10 +59,15 @@ public function hasDefinition($plugin_id) {
59
59
* {@inheritdoc}
60
60
*/
61
61
public function createInstance ($ plugin_id , array $ configuration = array ()) {
62
- // @todo: Use ->expandArguments() when get() disallows getting private
63
- // services.
64
- $ plugin = clone $ this ->container ->get ($ this ->servicePrefix . $ plugin_id );
65
- return $ plugin ;
62
+ $ plugin_definition = $ this ->getDefinition ($ plugin_id );
63
+ $ plugin_definition += array (
64
+ 'arguments ' => array (),
65
+ );
66
+
67
+ array_unshift ($ plugin_definition ['arguments ' ], $ plugin_id );
68
+ array_unshift ($ plugin_definition ['arguments ' ], $ configuration );
69
+
70
+ return $ this ->container ->createInstance ($ this ->servicePrefix . $ plugin_id , $ plugin_definition );
66
71
}
67
72
68
73
/**
You can’t perform that action at this time.
0 commit comments