Search code examples
phpzend-frameworkzend-controller

Is there an easy way to apply logging (e.g. Zend_Log) to Zend_Controller_Action_Helper_Redirector?


I've got an application which seems to be stuck in a redirect loop when I put it in a subdirectory of my server (e.g. blah.com/testing/ instead of blah.com/), despite sharing the same code. I think I've handled the redirection stuff incorrectly, but Apache's debugging output doesn't actually list the redirections, because they're being handled inside PHP.

Is there an easy way to attach a logger to the redirection function?


Solution

  • class My_Controller_Action_Helper_Redirector extends Zend_Controller_Action_Helper_Redirector
    {
        protected function _redirect($url)
        {
            $this->myPrettyLoggingFunction();
            parent::_redirect($url);
        }
    }
    

    if My_ namespace configured right, this plugin will be loaded by PluginLoader instead of default Zend_Controller_Action_Helper_Redirector

    usage - standard way $this->_helper->redirector(...)