Quantcast

ServiceManager Di Fallback

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

ServiceManager Di Fallback

macest
This post has NOT been accepted by the mailing list yet.
I have a service which is instantiated via the Di and injected into a controller via a ServiceManager factory, which works just fine. However the trouble comes when I want to get this instance from an event (in this case Zend\Mvc\Application::route) that occurs prior to a controller being instantiated. This appears to be due to the DiServiceInitializer, which creates a proxy between the Di and ServiceManager in the ControllerLoaderFactory, not being available until a controller is requested. It seems to me that this proxy should be created earlier on in the Application process so it is usable in such events. Any thoughts?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: ServiceManager Di Fallback

richard
This post has NOT been accepted by the mailing list yet.
If you override/extend Zend\Mvc\Service\ApplicationFactory you could add a DiServiceInitializer to the serviceLocator.

This would mean that the ServiceManager in Application would have the proxy between the service manager and di, enabling you to use di and service factories together immediately after the Application object is created.

Regards
Loading...