示例#1
0
 public function __invoke($data = null)
 {
     $controller = $this->getController();
     $data = $data == null ? H\GTResult::to() : ($data instanceof GTBaseTableGateway ? $data->result() : $data);
     $request = $controller->getRequest();
     if ($request->isXmlHttpRequest()) {
         $result = array("error" => true, "result" => array("message" => "The server has returned empty response.", "code" => 0));
         if (is_array($data) && count($data) > 0) {
             $result["error"] = isset($data["error"]) ? $data["error"] : false;
             unset($data["error"]);
             $result["result"] = isset($data["result"]) ? $data["result"] : $data;
             $result["result"]["code"] = isset($data["code"]) ? $data["code"] : 0;
         } else {
             $result = H\GTResult::to();
         }
         return new JsonModel($result);
     }
     return $data;
 }
示例#2
0
 private function redirectIfDevMode($event_logger_id)
 {
     if ($this->_customConfig['developmentMode']) {
         if (!$this->_headerSignKey && !$this->_headerToken) {
             $redirect = "http://" . $_SERVER['SERVER_NAME'] . "/gtevent/show/event_id/" . $event_logger_id;
             echo "<a href='" . $redirect . "'>{$redirect}</a>";
         } else {
             $html = 'Event Id:' . $event_logger_id . '<br>';
             $html .= H\EventType::getName($this->_f_event_type) . '<br>';
             $html .= $this->_f_event_code . '<br>';
             $html .= $this->_f_event_file . ':' . $this->_f_line . '<br>';
             $html .= $this->_f_message . '<br>';
             $html .= $this->_f_stack_trace . '<br>';
             $html .= 'User Id:' . $this->_f_user_id . '<br>';
             $html .= 'Device Id:' . $this->_f_device_id . '<br>';
             $this->_result['result'] = H\GTResult::to($this->_default_error_message . $event_logger_id, true, $this->_customConfig['errorCodeResponse']);
             $this->_result['result'] = array('stack_trace' => $html, 'exception_message' => $this->_f_message, 'datetime' => $this->_f_date_time, 'message' => $this->_default_error_message . "{$event_logger_id}, {$this->_f_message}", 'code' => $this->_customConfig['errorCodeResponse']);
             $json = json_encode($this->_result);
             echo $json;
         }
     } else {
         $redirect = "http://" . $_SERVER['SERVER_NAME'] . "/gtevent/error";
         if ($this->_f_event_type == EventType::ERROR_PHP || $this->_f_event_type == EventType::EXCEPTION_DISPATCH || $this->_f_event_type == EventType::EXCEPTION_RENDER || $this->_f_event_type == EventType::EXCEPTION_PHP) {
             if (!$this->_headerSignKey && !$this->_headerToken) {
                 echo "<meta http-equiv='refresh' content='0;url={$redirect}'>";
             } else {
                 $this->_result['result'] = H\GTResult::to($this->_default_error_message . $event_logger_id, true, $this->_customConfig['errorCodeResponse']);
                 $json = json_encode($this->_result);
                 echo $json;
             }
             die;
         }
         if ($this->_f_event_type == EventType::ROUTER_NOT_MATCH) {
             if (!$this->_headerSignKey && !$this->_headerToken) {
                 echo "<meta http-equiv='refresh' content='0;url={$redirect}'>";
             } else {
                 $this->_result['result'] = H\GTResult::to($this->_default_error_message . $event_logger_id, true, $this->_customConfig['errorCodeResponse']);
                 $json = json_encode($this->_result);
                 echo $json;
             }
         }
     }
 }
 public function showAction()
 {
     $session = new Container('user');
     $pageNum = $session->page;
     $config = $this->getServiceLocator()->get('config');
     $customConfig = $config["GTErrorTracker"];
     $event_logger_id = $this->GTParam('event_logger_id', 0);
     $partial = $this->getServiceLocator()->get('viewhelpermanager')->get('partial');
     $customEvent = $this->GTGateway("EventLoggerGateway")->findByEventId($event_logger_id);
     $result = H\GTResult::to();
     if ($customEvent instanceof EventLogger) {
         $xdebug_message = $customEvent->get_xdebug_message() ? $partial("gt-error-tracker/event/xdebug_message.phtml", array("item" => $customEvent)) : "";
         $variables_dump = $customEvent->get_variables_dump() ? $partial("gt-error-tracker/event/variables_dump.phtml", array("item" => $customEvent)) : "";
         $trace_dump = $customEvent->get_trace_dump() ? $partial("gt-error-tracker/event/trace_dump.phtml", array("item" => $customEvent)) : "";
         $result = array("html" => $partial("gt-error-tracker/event/event_item.phtml", array("item" => $customEvent, "pageNum" => $pageNum, "xdebug_message" => $xdebug_message, "variables_dump" => $variables_dump, "trace_dump" => $trace_dump)));
     } else {
         $result = array("html" => $partial("gt-error-tracker/empty_list.phtml", array('message' => $result['message'])));
     }
     if (!$this->getRequest()->isPost()) {
         $this->GTHead("css", $customConfig['LoadCss']['showAction']);
         $this->GTHead("js", $customConfig['LoadJs']['showAction']);
     }
     return $this->GTResult($result);
 }
 public function isError()
 {
     return H\GTResult::isError();
 }