/** * Get a custom InfinitasErrorController instance * * This instance tries to load up the very minimum to display the error * page. If anything goes wrong it falls back to the default CakeErrorController * * @param Exception $exception The exception to get a controller for. * * @return Controller */ protected function _getController($exception) { App::uses('InfinitasErrorController', 'Controller'); if (!($request = Router::getRequest(true))) { $request = new CakeRequest(); } $response = new CakeResponse(array('charset' => Configure::read('App.encoding'))); try { return new InfinitasErrorController($request, $response); } catch (Exception $e) { return parent::_getController($exception); } }
/** * 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) { if (!($request = Router::getRequest(true))) { $request = new CakeRequest(); } // If outside of plugin, use default handling if ($request->params['plugin'] !== 'forum') { return parent::_getController($exception); } $response = new CakeResponse(array('charset' => Configure::read('App.encoding'))); $controller = new ForumAppController($request, $response); $controller->viewPath = 'Errors'; $controller->constructClasses(); $controller->startupProcess(); return $controller; }