コード例 #1
0
ファイル: Error.php プロジェクト: darkearl/projectT122015
 public static function noControllerResponse(XenForo_RouteMatch $routeMatch, Zend_Controller_Request_Http $request)
 {
     self::sendErrorPageHeaders();
     if (XenForo_Application::debugMode()) {
         echo 'Failed to get controller response and reroute to error handler (' . $routeMatch->getControllerName() . '::action' . $routeMatch->getAction() . ')';
         if ($request->getParam('_exception')) {
             echo self::getExceptionTrace($request->getParam('_exception'));
         }
     } else {
         echo self::_getPhrasedTextIfPossible('An unexpected error occurred. Please try again later.', 'unexpected_error_occurred');
     }
 }
コード例 #2
0
 /**
  * Executes the controller dispatch loop.
  *
  * @param XenForo_RouteMatch $routeMatch
  *
  * @return XenForo_ControllerResponse_Abstract|null Null will only occur if error handling is broken
  */
 public function dispatch(XenForo_RouteMatch &$routeMatch)
 {
     $reroute = array('controllerName' => $routeMatch->getControllerName(), 'action' => $routeMatch->getAction());
     $allowReroute = true;
     do {
         if (isset($reroute['path'])) {
             $routeMatch = $this->route($reroute['path']);
             $reroute = array('controllerName' => $routeMatch->getControllerName(), 'action' => $routeMatch->getAction());
         }
         $controllerResponse = null;
         $controllerName = $reroute['controllerName'];
         $action = str_replace(array('-', '/'), ' ', strtolower($reroute['action']));
         $action = str_replace(' ', '', ucwords($action));
         if ($action === '') {
             $action = 'Index';
         }
         $reroute = false;
         $controller = $this->_getValidatedController($controllerName, $action, $routeMatch);
         if ($controller) {
             try {
                 try {
                     $controller->preDispatch($action, $controllerName);
                     $controllerResponse = $controller->{'action' . $action}();
                 } catch (XenForo_ControllerResponse_Exception $e) {
                     $controllerResponse = $e->getControllerResponse();
                 }
                 $controller->postDispatch($controllerResponse, $controllerName, $action);
                 $reroute = $this->_handleControllerResponse($controllerResponse, $controllerName, $action);
             } catch (Exception $e) {
                 // this is a bit hacky, but it's a selective catch so it's a strange case
                 if ($e instanceof XenForo_Exception && $e->isUserPrintable()) {
                     $controllerResponse = $this->_getErrorResponseFromException($e);
                     $controller->postDispatch($controllerResponse, $controllerName, $action);
                 } else {
                     if (!$allowReroute) {
                         break;
                     }
                     $reroute = $this->_rerouteServerError($e);
                     $allowReroute = false;
                     XenForo_Error::logException($e);
                 }
             }
             $responseType = $controller->getResponseType();
             $this->_dependencies->mergeViewStateChanges($controller->getViewStateChanges());
         } else {
             if (!$allowReroute) {
                 break;
             }
             $reroute = $this->_rerouteNotFound($controllerName, $action);
             $allowReroute = false;
         }
     } while ($reroute);
     if ($controllerResponse instanceof XenForo_ControllerResponse_Abstract) {
         $controllerResponse->controllerName = $controllerName;
         $controllerResponse->controllerAction = $action;
     }
     return $controllerResponse;
 }