コード例 #1
0
 /**
  * Overriding _getController to use MPResponse instead of default one
  *
  * @see ExceptionRenderer::_getController
  * @param Exception $exception
  * @return CakeErrorController|Controller
  */
 protected function _getController($exception)
 {
     App::uses('AppController', 'Controller');
     App::uses('CakeErrorController', 'Controller');
     if (!($request = Router::getRequest(true))) {
         $request = new CakeRequest();
     }
     $response = new MPResponse();
     if (method_exists($exception, 'responseHeader')) {
         $response->header($exception->responseHeader());
     }
     if (class_exists('AppController')) {
         try {
             $controller = new CakeErrorController($request, $response);
             $controller->startupProcess();
         } catch (Exception $e) {
             if (!empty($controller) && $controller->Components->enabled('RequestHandler')) {
                 $controller->RequestHandler->startup($controller);
             }
         }
     }
     if (empty($controller)) {
         $controller = new Controller($request, $response);
         $controller->viewPath = 'Errors';
     }
     return $controller;
 }
コード例 #2
0
 /**
  * Get the controller instance to handle the exception.
  * Override this method in subclasses to customize the controller used.
  * This method returns the built in `CakeErrorController` normally, or if an error is repeated
  * a bare controller will be used.
  *
  * @param Exception $exception The exception to get a controller for.
  * @return Controller
  */
 protected function _getController($exception)
 {
     App::uses('AppController', 'Controller');
     App::uses('CakeErrorController', 'Controller');
     if (!($request = Router::getRequest(true))) {
         $request = new CakeRequest();
     }
     $response = new CakeResponse();
     if (method_exists($exception, 'responseHeader')) {
         $response->header($exception->responseHeader());
     }
     if (class_exists('AppController')) {
         try {
             $controller = new CakeErrorController($request, $response);
             $controller->startupProcess();
             $startup = true;
         } catch (Exception $e) {
             $startup = false;
         }
         // Retry RequestHandler, as another aspect of startupProcess()
         // could have failed. Ignore any exceptions out of startup, as
         // there could be userland input data parsers.
         if ($startup === false && !empty($controller) && $controller->Components->enabled('RequestHandler')) {
             try {
                 $controller->RequestHandler->startup($controller);
             } catch (Exception $e) {
             }
         }
     }
     if (empty($controller)) {
         $controller = new Controller($request, $response);
         $controller->viewPath = 'Errors';
     }
     return $controller;
 }
コード例 #3
0
 /**
  * Get the controller instance to handle the exception.
  * Override this method in subclasses to customize the controller used.
  * This method returns the built in `CakeErrorController` normally, or if an error is repeated
  * a bare controller will be used.
  *
  * @param Exception $exception The exception to get a controller for.
  * @return Controller
  */
 protected function _getController($exception)
 {
     App::uses('AppController', 'Controller');
     App::uses('CakeErrorController', 'Controller');
     if (!($request = Router::getRequest(true))) {
         $request = new CakeRequest();
     }
     $response = new CakeResponse(array('charset' => Configure::read('App.encoding')));
     try {
         $controller = new CakeErrorController($request, $response);
         $controller->startupProcess();
     } catch (Exception $e) {
         if (!empty($controller) && $controller->Components->enabled('RequestHandler')) {
             $controller->RequestHandler->startup($controller);
         }
     }
     if (empty($controller)) {
         $controller = new Controller($request, $response);
         $controller->viewPath = 'Errors';
     }
     return $controller;
 }