@@ -47,6 +47,7 @@ public function __construct()
47
47
'foo_bar ' => 'getFooBarService ' ,
48
48
'foo_with_inline ' => 'getFooWithInlineService ' ,
49
49
'method_call1 ' => 'getMethodCall1Service ' ,
50
+ 'new_factory ' => 'getNewFactoryService ' ,
50
51
'new_factory_service ' => 'getNewFactoryServiceService ' ,
51
52
'request ' => 'getRequestService ' ,
52
53
'service_from_static_method ' => 'getServiceFromStaticMethodService ' ,
@@ -282,10 +283,7 @@ protected function getMethodCall1Service()
282
283
*/
283
284
protected function getNewFactoryServiceService ()
284
285
{
285
- $ a = new \FactoryClass ();
286
- $ a ->foo = 'bar ' ;
287
-
288
- $ this ->services ['new_factory_service ' ] = $ instance = $ a ->getInstance ();
286
+ $ this ->services ['new_factory_service ' ] = $ instance = $ this ->get ('new_factory ' )->getInstance ();
289
287
290
288
$ instance ->foo = 'bar ' ;
291
289
@@ -328,6 +326,27 @@ protected function synchronizeRequestService()
328
326
}
329
327
}
330
328
329
+ /**
330
+ * Gets the 'new_factory' service.
331
+ *
332
+ * This service is shared.
333
+ * This method always returns the same instance of the service.
334
+ *
335
+ * This service is private.
336
+ * If you want to be able to request this service from the container directly,
337
+ * make it public, otherwise you might end up with broken code.
338
+ *
339
+ * @return \FactoryClass A FactoryClass instance.
340
+ */
341
+ protected function getNewFactoryService ()
342
+ {
343
+ $ this ->services ['new_factory ' ] = $ instance = new \FactoryClass ();
344
+
345
+ $ instance ->foo = 'bar ' ;
346
+
347
+ return $ instance ;
348
+ }
349
+
331
350
/**
332
351
* {@inheritdoc}
333
352
*/
0 commit comments