-- ghola <[email protected]> wrote (on Monday, 19 March 2012, 07:42 AM -0700): > Imagine the following situation: > You have several event handlers defined as services. These event handlers > need to have several other services injected into them (say you have an > invokable EmailUserOnNewAccountCreatedEventHandler that requires a Zend_Mail > instance and a Zend_Db instance). > > Now in order to attach these handlers to your EventManger instance (which > could itself be a service and have attaching made through Di) you will need > to instantiate all of them (you cannot pass just the class name because the > CallbackHandler object will not know to inject your dependencies). This is > obviously bad, because instantiating them will in turn instantiate their all > dependencies. > > The above is actually the only scenario i am using the new ZF2 EventManager > for right now. > > So the EventManager needs to handle these situations correctly, be Di > enabled, and lazy load the handler instances. If by any chance this is > already possible, please let me know how i can achieve it.
I'm not sure what advantage you get from lazy-loading the listeners vs. simply instantiating with dependencies and attaching -- or, rather, what disadvantage there is to this latter approach. Can you explain why this is a problem? -- 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]
