In init() of the abstract CrudController:
  $this->_helper->viewRenderer->setViewBasePathSpec(Bootstrap::
$root.'/application/views');
  $this->_helper->viewRenderer-
setViewScriptPathSpec('crud/:action.:suffix');
  $this->_helper->viewRenderer->initView();

This will work, but the problem is that when an action is redirected,
the ViewRenderer is all messed up. For example, if an error ocurrs, it
will try to render crud/error.phtml instead of error/error.phtml.

I could do pre/postDispatch magic here, bit it seems dirty.

Actually, that's a good way to do it -- have the controller clean up
after itself. Ideally, we should likely have the ErrorController setup
some sane defaults -- and you could, potentially, have it do just that.


I don't like the idea of having ErrorController clean up other's mess. Ideally, the "environment" (ViewRenderer) shouldn't be modified by the actions, or, like you said, they should restore old settings after running.

So your first suggestion seems the way to go, but as far as I can see, the controller's postDispatch won't get called if the action method throws an exception (I'm looking at Zend_Controller_Action::dispatch(), where there's no try/catch block around "$this->__call($action, array());"). So if an exception ocurred, the controller wouldn't have the chance to "clean up" the ViewRenderer and this isn't going to work :(




Reply via email to