On Thu, Feb 27, 2014 at 11:48 AM, Marco Pivetta <[email protected]> wrote:

>
> On 27 February 2014 20:37, Philip G <[email protected]> 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
>

Ah. Then abstract_factory should be moved into Zend\Mvc, or
zend-servicemanager needs to become non-dependent on Zend\Mvc auto-sets.



>
> 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 ;-)
>

I can get that. But, I'm intentionally using Zend\ServiceManager and
Zend\Db conjointly for this functionality. It shouldn't be assuming I'm
using it within context of Zend\Mvc, a non-explicit dependency.



>
>
>
>> 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,
>
>
>
So, what happened is Zend\ServiceManager has became dependent on Zend\Mvc.
Oops! Looks like some work needs to be done within Zend\ServiceManager. ;)

I am 100% properly creating a new ServiceManager instance, without any
conflicts or issues within any other component of ServiceManager.
abstract_factory should to be updated so that it, too, isn't dependent on
Zend\Mvc.

I'll look into it, too, but this is a new piece to me I just discovered
today -- seemed to fit my needs (I have 3 different db adapters I need to
manage ... owie!). And I don't know all the potential implications or
thought-process around the design decisions for abstract_factory. At the
base, abstract_factory needs to become config aware upon
$sm->addAbstractFactory().

---
Philip
[email protected]
http://www.gpcentre.net/

Reply via email to