Question

This below function in Bootstrap class for adding log in DB for errors.Now I have to redirect it to Dashboard using Flashmessenger and Redirector helpers.but it throws fatal error.

protected function _initDebug()
{
    register_shutdown_function(function () {
        if ($e = error_get_last()) {
            Zend_Registry::get('logger')->emerg($e['message'] . " in " . $e['file'] . ' line ' . $e['line'], 'error');
            $logsDbTable = new Application_Model_DbTable_Logs();
            $id = $logsDbTable->getLastInsertId();
            $message = sprintf(Zend_Registry::getInstance()->config->ticket_msg,$id,Zend_Registry::getInstance()->config->support_phone_number);
            $this->_helper->FlashMessenger(array('error' => $message));
            $this->_helper->_redirector->goToSimple('index', 'dashboard');              
        }
    });
}
Was it helpful?

Solution

As You haven't registered Zend_Controller_Action_HelperBroker you have to instantiate helper manually. I haven't checked it but it should work.

protected function _initDebug()
{
    register_shutdown_function(function () {
        if ($e = error_get_last()) {
            Zend_Registry::get('logger')->emerg($e['message'] . " in " . $e['file'] . ' line ' . $e['line'], 'error');
            $logsDbTable = new Application_Model_DbTable_Logs();
            $id = $logsDbTable->getLastInsertId();
            $message = sprintf(Zend_Registry::getInstance()->config->ticket_msg,$id,Zend_Registry::getInstance()->config->support_phone_number);
            $fm = new Zend_Controller_Action_Helper_FlashMessenger();
            $fm->addMessage(array('error' => $message));//$this->_helper->FlashMessenger(array('error' => $message));
            $rd = new Zend_Controller_Action_Helper_Redirector();
            $rd->goToSimple('index', 'dashboard');//$this->_helper->_redirector->goToSimple('index', 'dashboard');              
        }
    });
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top