-- ghola <[email protected]> wrote
(on Wednesday, 21 March 2012, 05:07 AM -0700):
> Looking over the code in more detail, the simplest way this can be achieved
> is by making some small modifications to the Zend\Stdlib\CallbackHandler
> class by broadening the definition of 'callback'. From my understanding, the
> intent of the CallbackHandler is to abstract PHP callbacks, and while doing
> so it might also escape from the limited definition given by is_callable.

> A callback could also be represented by an array with 2 elements, the first
> one implementing a Zend\Di\Locator interface and the second one being a
> string (representing a service name). 
> array( $locator, $name );

I actually stripped out functionality that lazy-loaded due to the
performance hit incurred from using Reflection. While we could allow
injecting the Locator, this also means that the EM would need to be
locator aware, and this feels like way too much coupling for something
like this -- it requires a ton of domain knowledge to ensure that each
EM gets a locator, and that the classes you use as listeners can be
located, etc.

> The CallbackHandler::getCallback() function could then call on the Locator's
> get() method passing in the $name in order to obtain an instance of service.
> 
> Making the CallbackHandler depend on a Di interface might be weird and
> unrecommended, so a solution would be to move the Locator interface to the
> Stdlib package.

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to