public function get_response() { if (Kohana::$environment >= Kohana::DEVELOPMENT) { return parent::get_response(); } else { $view = View::factory('templates/errors/default'); $view->set('title', "404 Not Found"); $view->set('message', "{$this->getMessage()}"); $response = Response::factory()->status(404)->body($view->render()); return $response; } }
/** * Generate a Response for the 404 Exception. * * @return Response */ public function get_response() { $ext = pathinfo(Request::current()->url(), PATHINFO_EXTENSION); $mimetype = FALSE; if ($ext and !($mimetype = File::mime_by_ext($ext))) { $mimetype = 'application/octet-stream'; } if ($mimetype) { return Response::factory()->headers('content-type', $mimetype)->status(404); } else { return parent::get_response(); } }
/** * Generate a Response for the 404 Exception. * * Page Not Found * The user should be shown a nice 404 page. * * @return Response */ public function get_response() { // Lets log the Exception, Just in case it's important! Kohana_Exception::log($this); if (Kohana::$environment >= Kohana::DEVELOPMENT) { // Show the normal Kohana error page. return parent::get_response(); } else { // Get tpl directory $front_tpl_dir = Cms_Helper::settings('front_tpl_dir'); // Get file $content_file = Tpl::get_file($this->code, $front_tpl_dir . '/error'); // Todo:: 「,」「.」とか入るときはカレントRULとれないから。 $request_url = $this->request()->current() ? $this->request()->current()->uri() : __('not know'); // Set variable and render $content = Tpl::factory($content_file)->set('code', $this->getCode())->set('message', $this->getMessage())->set('request_url', $request_url)->render(); // Factory response $response = Response::factory(); $response->body($content); return $response; } }