php - How to add new listener in the best way? -


i have project on zf 1.x , want use eventdispatcher symfony component. have 2 services user , topic. after success user authentication need activate user's topics. create event - authenticationevent , fire event after authentication in user service this

$dispatcher->dispatch('user.authentication.success', new authenticationevent($user)); 

but need add listener? code looks like

$listener = new topiclistener(); $dispatcher->addlistener('user.authentication.success', array($listener, 'onauthenticationaction')); 

i had method authenticate in user service , there code lines calling method activate($user) activate topics in success case of authentication. whereupon had coupling between user , topic service. why decided use eventdispatcher.

so best place adding listeners? in bootstrap part of code?

i don't know zf. must add listener before dispatch event.

has "bootsrap" file? add listener there (or in front controller).


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -