How to create factories for Plugin or Helper Managers?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to create factories for Plugin or Helper Managers?

Александр Шелковский
Hello.

If I want to register factory which implements Zend\ServiceManager\FactoryInterface in Zend\ServiceManager\AbstractPluginManager I can't have access to Zend\ServiceManager\AbstractPluginManager::getServiceLocator in Zend\ServiceManager\FactoryInterface::createService(ServiceLocatorInterface $serviceLocator) becaue it expect ServiceLocatorInterface but not ServiceLocatorAwareInterface .

What is the best way if I need to have access to 'parent' service locator in factory?

Regards,
Alex.
Reply | Threaded
Open this post in threaded view
|

Re: How to create factories for Plugin or Helper Managers?

Richard Holloway

On 25/09/12 22:25, Александр Шелковский wrote:

> Hello.
>
> If I want to register factory which implements
> Zend\ServiceManager\FactoryInterface in
> Zend\ServiceManager\AbstractPluginManager I can't have access to
> Zend\ServiceManager\AbstractPluginManager::getServiceLocator in
> Zend\ServiceManager\FactoryInterface::createService(ServiceLocatorInterface
> $serviceLocator) becaue it expect ServiceLocatorInterface but not
> ServiceLocatorAwareInterface .
>
> What is the best way if I need to have access to 'parent' service
> locator in factory?
>
> Regards,
> Alex.


Sorry to hijack the thread but I have a similar problem with getting
configuration settings into custom InputFilters. Can it be done in ZF 2.0 ?
Reply | Threaded
Open this post in threaded view
|

Re: How to create factories for Plugin or Helper Managers?

Jurian Sluiman
In reply to this post by Александр Шелковский
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: How to create factories for Plugin or Helper Managers?

Александр Шелковский
However, it gives you troubles because you can't override the method's signature in php. You are stuck with closures or you must duck typing by calling $sm->getServiceLocator() on $sm an instance of ServiceLocatorInterface.
That is what I do now. I call ServiceLocatorInterface::getServiceLocator, but its quite ugly code. Probably Zend team must create some issue in order to fix this problem? Or we should ignore it and use callbacks as factories?