Search code examples
zend-frameworkviewrendering

Zend addScriptPath in postDispatch?


is it a good idea to add a script path in postDispatch of a controller? Or is the init() or preDispatch() function a better place for it?

public function postDispatch() {
   $this->view->addScriptPath( path/to/scripts );
}

In fact adding a script path in postDispatch does not work correctly.

So where I should put it - init() or preDispatch()?


Solution

  • I would vote for init() in your case. As there is nothing changed in dispatching loop there is no sense using preDispatch. But it's going to work in both cases.

    In my zf project we have modules so we have addScriptPath calls in module initialization files.