php - ZF2 Get ServiceManager from Controller Plugin Factory -


I am trying to create a new controller plugin using a factory for a dependency injection.

  public function createService (ServiceLocatorInterface $ serviceLocator) {$ services = $ serviceLocator- & gt; GetServiceLocator (); / ** @ War \ Zend \ MVC \ Controller \ PluginManager * / $ Plugin = New MyPlugin (); If ($ services- & gt; ('my_service') is) {$ plugin- & gt; Set service ($ services- & gt; receive ('my_service')); } $ Plugin returned;   

The problem is that $ services can not get 'my_service'

I've added the appropriate configuration to my service manager

  'Services' = & gt; Array ('invokables' = & gt; array ('my_service' = & gt; 'application \ service \ myswive')), 'admin_plugin' = & gt; Array ('factory' => array ('my_plugin' => 'application \ controller \ plugin \ factory \ myplugin'))   

I think that in this plugin manager It's a bug, it is not properly injection to the service manager.

I have the proper configuration of my service manager

service The key for the manager configuration is service_memory , not the services which is the reason why your Incognito has not been found ...

  'service_manager '= & Gt; Array ('invokables' = & gt; array ('my_service' = & gt; 'application \ service \ myswive')), // ...    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -