On Fri, Jan 11, 2013 at 5:45 PM, Gavin Staniforth <[email protected]> wrote: > Namespaced 'dispatch.error' Events. > > $sharedEvents = > $e->getApplication()->getEventManager()->getSharedManager(); > $sharedEvents->attach(__NAMESPACE__, 'dispatch', > function($e) { > die('test'); > }, 100); > > The above will trigger and only trigger in the module to which is under > __NAMESPACE__ > > However .error doesnt seem to trigger at all? Is this expected? whats the > logic to having a error trigger for a certain module instead of having it > global across the application? > > $sharedEvents = > $e->getApplication()->getEventManager()->getSharedManager(); > $sharedEvents->attach(__NAMESPACE__, > 'dispatch.error', function($e) { > die('test'); > }, 100);
I don't understand what your question is... In the first case, you attached only to "dispatch", but your listener calls "die", which halts program execution; as such, there's no way that dispatch.error could be triggered, unless a listener at higher priority triggers it. You later ask "whats the logic to having a error trigger for a certain module instead of having it global across the application?" Well, as written, it will not trigger. dispatch.error is an Application event, not a controller event -- in other words, a controller will never trigger it, only the Application instance will. Furthermore, the Application class only publishes on the contexts of "Application", "Zend\Mvc\Application", and "Zend\Mvc\ApplicationInterface"; a namespace-specific listener will never trigger. -- 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]
