This repository was archived by the owner on Feb 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ public function has($name)
236
236
237
237
// Check abstract factories
238
238
foreach ($ this ->abstractFactories as $ abstractFactory ) {
239
- if ($ abstractFactory ->canCreate ($ this , $ name )) {
239
+ if ($ abstractFactory ->canCreate ($ this -> creationContext , $ name )) {
240
240
return true ;
241
241
}
242
242
}
@@ -605,7 +605,7 @@ private function getFactory($name)
605
605
606
606
// Check abstract factories
607
607
foreach ($ this ->abstractFactories as $ abstractFactory ) {
608
- if ($ abstractFactory ->canCreate ($ this , $ name )) {
608
+ if ($ abstractFactory ->canCreate ($ this -> creationContext , $ name )) {
609
609
return $ abstractFactory ;
610
610
}
611
611
}
Original file line number Diff line number Diff line change 16
16
use Zend \ServiceManager \Exception \InvalidArgumentException ;
17
17
use Zend \ServiceManager \Exception \InvalidServiceException ;
18
18
use Zend \ServiceManager \Exception \ServiceNotFoundException ;
19
+ use Zend \ServiceManager \Factory \AbstractFactoryInterface ;
19
20
use Zend \ServiceManager \Factory \FactoryInterface ;
20
21
use Zend \ServiceManager \Factory \InvokableFactory ;
21
22
use Zend \ServiceManager \ServiceManager ;
@@ -349,4 +350,17 @@ public function testPassingServiceInstanceViaConfigureShouldRaiseExceptionForInv
349
350
stdClass::class => new stdClass (),
350
351
]]);
351
352
}
353
+
354
+ public function testAbstractFactoryGetsCreationContext ()
355
+ {
356
+ $ serviceManager = new ServiceManager ();
357
+ $ pluginManager = new TestAsset \SimplePluginManager ($ serviceManager );
358
+ $ abstractFactory = $ this ->prophesize (AbstractFactoryInterface::class);
359
+ $ abstractFactory ->canCreate ($ serviceManager , 'foo ' )
360
+ ->willReturn (true );
361
+ $ abstractFactory ->__invoke ($ serviceManager , 'foo ' , null )
362
+ ->willReturn (new InvokableObject ());
363
+ $ pluginManager ->addAbstractFactory ($ abstractFactory ->reveal ());
364
+ $ this ->assertInstanceOf (InvokableObject::class, $ pluginManager ->get ('foo ' ));
365
+ }
352
366
}
You can’t perform that action at this time.
0 commit comments