public function execute(Request $request)
 {
     if ($this->callback_depth() > $this->max_callback_depth()) {
         throw new Request_Client_Recursion_Exception("Could not execute request to :uri - too many recursions after :depth requests", array(":uri" => $request->uri(), ":depth" => $this->callback_depth() - 1));
     }
     $orig_response = $response = Response::factory(array("_protocol" => $request->protocol()));
     if (($cache = $this->cache()) instanceof HTTP_Cache) {
         return $cache->execute($this, $request, $response);
     }
     $response = $this->execute_request($request, $response);
     foreach ($this->header_callbacks() as $header => $callback) {
         if ($response->headers($header)) {
             $cb_result = call_user_func($callback, $request, $response, $this);
             if ($cb_result instanceof Request) {
                 $this->assign_client_properties($cb_result->client());
                 $cb_result->client()->callback_depth($this->callback_depth() + 1);
                 $response = $cb_result->execute();
             } elseif ($cb_result instanceof Response) {
                 $response = $cb_result;
             }
             if ($response !== $orig_response) {
                 break;
             }
         }
     }
     return $response;
 }
Example #2
0
 public function get_response()
 {
     $view = View::factory('error/500');
     $view->message = $this->getMessage();
     $response = Response::factory()->status(500)->body($view->render());
     return $response;
 }
 public function get_response()
 {
     $twig = Twig::factory('frontend/main');
     $response = $twig->render('Public/404');
     $response = Response::factory()->status(404)->body($response);
     return $response;
 }
 /**
  * Attempt to query error/500 manually, as we cannot catch exceptions through traditional HMVC requests.
  * Catch potential exceptions such as database is down and display a lightweight error message.
  *
  * @param Exception $e
  * @return Response
  */
 public static function response(Exception $e)
 {
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         return parent::response($e);
     }
     try {
         // Create the request, we need to set controller and action manual as they
         // otherwise gets set in execute method.
         $request = Request::factory();
         $request->controller(Kohana_Exception::$_controller);
         $request->action(Kohana_Exception::$_method);
         // Setup the response object
         $response = Response::factory();
         $response->status(500);
         $response->headers('Content-Type', Kohana_Exception::$error_view_content_type . '; charset=' . Kohana::$charset);
         // Call the controller.
         $controller = new Controller_Error($request, $response);
         return $controller->execute();
     } catch (Exception $e) {
         // Render the fallback view.
         $view = View::factory('errors/fallback');
         $response = Response::factory();
         $response->status(500);
         $response->body($view->render());
         return $response;
     }
 }
Example #5
0
 public function get_response()
 {
     $response = Response::factory();
     $view = View::factory('errors/403');
     $response->body($view->render());
     return $response;
 }
Example #6
0
 public function get_response()
 {
     // HTTP/404.php - это файл шаблона, можно указать другой файл
     $view = View::factory('HTTP/404');
     $view->message = $this->getMessage();
     $response = Response::factory()->status(404)->body($view->render());
     return $response;
 }
Example #7
0
 /**
  * Generate a Response for the 404 Exception.
  *
  * The user should be shown a nice 404 page.
  * 
  * @return Response
  */
 public function get_response()
 {
     $view = View::factory('errors/404');
     // Remembering that `$this` is an instance of HTTP_Exception_404
     $view->message = $this->getMessage();
     $response = Response::factory()->status(404)->body($view->render());
     return $response;
 }
Example #8
0
 public function get_response()
 {
     $view = new View_Error_404();
     $renderer = Kostache_Layout::factory('404');
     $response = Response::factory()->status(404);
     $response->body($renderer->render($view));
     return $response;
 }
Example #9
0
 /**
  * Generate a Response for the 401 Exception.
  *
  * Unauthorized / Login Requied
  * The user should be redirect to a login page.
  *
  * @return Response
  */
 public function get_response()
 {
     // Todo:: これはどうつくるの?
     // Get tpl directory
     $home_page = Cms_Helper::settings('home_page');
     $response = Response::factory()->status(401)->headers('Location', URL::site($home_page, 'http'));
     return $response;
 }
Example #10
0
 public function get_response()
 {
     $response = Response::factory();
     $view = Kotwig_View::factory('errors/500');
     $response->status(500);
     $response->body($view->render());
     return $response;
 }
Example #11
0
 public function __construct()
 {
     $this->request = Request::current();
     if ($this->request->controller() == "Clients" && $this->request->action() == "detail") {
         $this->current_client = new Model_Client($this->request->param('id'));
         return $this->current_client;
     }
     parent::__construct(Request::current(), Response::factory());
 }
Example #12
0
 public function get_response()
 {
     $response = Response::factory();
     $view = View::factory('errors/404');
     // We're inside an instance of Exception here, all the normal stuff is available.
     $view->message = $this->getMessage();
     $response->body($view->render());
     return $response;
 }
Example #13
0
 /**
  * Generate a Response for the 404 Exception.
  *
  * The user should be shown a nice 404 page.
  * 
  * @return Response
  */
 public function get_response()
 {
     //return;
     $view = View::factory('404view');
     // Remembering that `$this` is an instance of HTTP_Exception_404
     // $view->message = $this->getMessage();
     $view->message = "Страница не найдена";
     $response = Response::factory()->status(404)->body($view->render());
     return $response;
 }
Example #14
0
 /**
  * Generates a Response for all Exceptions without a specific override
  *
  * @return Response
  */
 public function get_response()
 {
     // Log the exception
     Kohana_Exception::log($this);
     $response = Response::factory();
     $view = Swiftriver::get_base_error_view();
     $view->content = View::factory('pages/errors/404')->set('page', $this->request()->uri());
     $response->body($view->render());
     return $response;
 }
 /**
  * @return Response
  */
 public function send()
 {
     $this->_setProperAccountancyMonth();
     $content = $this->_invoice->toJson();
     $this->_initCurrentCurl(self::API_INVOICE_URL);
     $key = Utils::hexToStr($this->_getConfig()->{Config::API_KEY_INVOICE});
     $messageHash = Utils::hmac($key, sprintf("%s%s%s%s", self::API_INVOICE_URL, $this->_getConfig()->{Config::API_LOGIN}, Config::API_KEY_INVOICE_NAME, $content));
     $this->_setCurlPostOptions(self::API_INVOICE_URL, $this->_getRequestHeaders($messageHash), $content);
     return Response::factory(curl_exec($this->_currentCurl));
 }
Example #16
0
 public function get_response()
 {
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         return parent::get_response();
     } else {
         $response = Response::factory()->status(401)->headers('Location', URL::site('/'));
         return $response;
     }
 }
 /**
  * 
  * @return Response
  */
 public function sendInvoiceBasedOnProforma()
 {
     $this->_setProperAccountancyMonth();
     $requestUrl = sprintf("%s%s.%s", self::API_GET_INVOICE_PROFORMA_ADD_URL, InvoiceAbstract::filterNumber($this->_invoice->{InvoiceProformaResponse::KEY_PELNY_NUMER}), self::DEFAULT_CONNECTION_FILE_TYPE);
     $this->_initCurrentCurl($requestUrl);
     $key = Utils::hexToStr($this->_getConfig()->{Config::API_KEY_INVOICE});
     $messageHash = Utils::hmac($key, sprintf("%s%s%s", $requestUrl, $this->_getConfig()->{Config::API_LOGIN}, Config::API_KEY_INVOICE_NAME));
     $this->_setCurlGetOptions($requestUrl, $this->_getRequestHeaders($messageHash));
     return Response::factory(curl_exec($this->_currentCurl));
 }
Example #18
0
 /**
  * Exception handler, logs the exception and generates a 
  * Response object for display
  *
  * @param   Exception $e
  * @return  boolean
  */
 public static function _handler(Exception $e)
 {
     // Log the error
     Kohana::$log->add(Log::ERROR, $e->getMessage());
     // Generate the response
     $response = Response::factory();
     $view = Swiftriver::get_base_error_view();
     $view->content = View::factory('pages/errors/default');
     $response->body($view->render());
     return $response;
 }
Example #19
0
 /**
  * Get a Response object representing the exception
  *
  * @uses    Kohana_Exception::text
  * @param   Exception  $e
  * @return  Response
  */
 public static function response(Exception $e)
 {
     // Prepare the response object.
     $response = Response::factory();
     // Set the response status
     $response->status($e instanceof HTTP_Exception ? $e->getCode() : 500);
     // Set the response headers
     $response->headers('Content-Type', Kohana_Exception::$error_view_content_type . '; charset=' . Kohana::$charset);
     // Set the response body
     $response->body(self::text($e));
     return $response;
 }
Example #20
0
 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;
     }
 }
Example #21
0
 public static function response(Exception $e)
 {
     // handle error
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         return parent::response($e);
     } else {
         $view = new View('templates/errors/default');
         $view->set('title', "500 Internal Server Error");
         $view->set('message', "{$e->getMessage()}");
         $response = Response::factory()->status(500)->body($view->render());
         return $response;
     }
 }
Example #22
0
 public function get_response()
 {
     // Get the exception information
     $code = $this->getCode();
     $message = $this->getMessage();
     // $file    = $this->getFile();
     // $line    = $this->getLine();
     // $trace   = $this->getTrace();
     $response = Response::factory();
     $response->headers($this->_headers)->send_headers();
     header(HTTP::$protocol . ' ' . $code . ' ' . $message);
     exit(1);
 }
Example #23
0
 /**
  * Generate a Response for all Exceptions without a more specific override
  *
  * The user should see a nice error page, however, if we are in development
  * mode we should show the normal Kohana error page.
  *
  * @return Response
  */
 public static function response(Exception $e)
 {
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         // Show the normal Kohana error page.
         //return parent::response();
     }
     $view = View::factory('index');
     $view->content = View::factory('404');
     $view->title = 'Page not found';
     $view->current_url = '';
     $response = Response::factory()->status(404)->body($view->render());
     return $response;
 }
Example #24
0
 public function get_response()
 {
     $this->user = Auth::instance()->get_user();
     $this->detect_language();
     $response = Response::factory();
     $view = Kotwig_View::factory('errors/404');
     $response->status(404);
     if ($this->getMessage()) {
         $view->set('no_translation', $this->getMessage());
     }
     $response->body($view->render());
     return $response;
 }
Example #25
0
 public function get_response()
 {
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         return parent::get_response();
     } else {
         $view = View::factory('templates/errors/default');
         $view->set('title', 'Произошла ошибка');
         $view->set('message', "({$this->getCode()}) {$this->getMessage()}");
         $response = Response::factory()->status($this->getCode())->body($view->render());
         return $response;
     }
 }
Example #26
0
 /**
  * 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();
     }
 }
Example #27
0
 /**
  * Get a Response object representing the exception
  *
  * @uses    Kohana_Exception::text
  * @param   Exception  $e
  * @return  Response
  */
 public static function response($e)
 {
     if (Kohana::$environment === Kohana::DEVELOPMENT) {
         // Show the normal Kohana error page.
         return parent::response($e);
     } else {
         // Lets log the Exception, Just in case it's important!
         Kohana::$log->add(Log::ERROR, parent::text($e));
         // Generate a nicer looking "Oops" page.
         $view = View::factory('pages/error/default', array('message' => $e->getMessage()));
         $response = Response::factory()->status(500)->body($view->render());
         return $response;
     }
 }
Example #28
0
 /**
  * Generate a Response for all Exceptions without a more specific override
  *
  * The user should see a nice error page, however, if we are in development
  * mode we should show the normal Kohana error 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 {
         // Generate a nicer looking "Oops" page.
         $view = View::factory('error/default');
         $response = Response::factory()->status($this->getCode())->body($view->render());
         return $response;
     }
 }
Example #29
0
 /**
  * NegoCore HTTP Error handler
  *
  * @return Response
  */
 public function get_response()
 {
     if (Kohana::$environment == Kohana::DEVELOPMENT) {
         return parent::get_response();
     } else {
         $params = array('code' => $this->getCode(), 'message' => rawurlencode($this->getMessage()));
         try {
             $request = Request::factory(Route::get('error')->uri($params), array(), false)->execute()->send_headers(true)->body();
             return Response::factory()->status($this->getCode())->body($request);
         } catch (Exception $e) {
             return parent::get_response();
         }
     }
 }
Example #30
0
 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 and $mimetype !== 'text/html') {
         return Response::factory()->headers('content-type', $mimetype)->status(404);
     }
     if (($page = Model_Page_Front::findByField('behavior_id', 'page_not_found')) !== FALSE) {
         return Request::factory($page->url)->query('message', $this->message)->execute()->status(404);
     }
     throw new HTTP_Exception_404('Something went wrong');
 }