On 27 February 2014 20:37, Philip G <guice...@gmail.com> wrote: > I'm creating a new ServiceManager instance and a abstract_factory instance > is failing to load. > > Found out the root of the issue is $services->has('Config') fails within > Zend\Db\Adapter\AdapterAbstractServiceFactory::getConfig() line number 71. >
That is normal - such a factory was thought to be used in the context of a standard ZF2 Zend\Mvc based application I would have assumed new ServiceManager(new Config()); would have > automatically set the Config service to the Config I passed in ... > apparently, it does not. > > Automagic is not a good idea here ;-) > One solution is to add this line, within > Zend\ServiceManager\Config::configureServiceManager(): > -- > $serviceManager->setService('Config', $this->config); > -- > > However, I'm unaware of the implications to that. 'Config' is obviously > being set somewhere else for abstract_factory to pass unit tests. But > where? I'm running a very slim-down, component-by-component, based app; I > only import zend-servicemanager, zend-db, and zend-http. > > The "Config" service is usually defined by Zend\Mvc: https://github.com/zendframework/zf2/blob/df6fa23483c990f3ac47400f7191a337d979b5ac/library/Zend/Mvc/Service/ConfigFactory.php The factory is registered in the ServiceListenerFactory: https://github.com/zendframework/zf2/blob/df6fa23483c990f3ac47400f7191a337d979b5ac/library/Zend/Mvc/Service/ServiceListenerFactory.php#L44 Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/