0

Bootstrap类中的以下函数用于log在 DB 中添加错误。现在我必须使用 Flashmessenger 和 Redirector helpers 将其重定向到仪表板。但它会引发致命错误。

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');              
        }
    });
}
4

1 回答 1

1

由于您尚未注册 Zend_Controller_Action_HelperBroker,您必须手动实例化助手。我还没有检查它,但它应该工作。

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');              
        }
    });
}
于 2013-07-10T09:44:14.287 回答