Exemplo n.º 1
0
 /**
  * Prepares the response object to return an HTTP Redirect response to the client.
  *
  * @param string  $route     The redirect destination like controller/action
  * @param boolean $permanent If permanent redirection or not.
  * @param boolean $exit
  */
 public function redirect($route, $permanent = false, $exit = true)
 {
     $url = Url::compute($route);
     Header::clear();
     $permanent === true ? Header::sendMovedPermanently() : Header::sendFound();
     Header::toLocation($url, $exit);
 }
Exemplo n.º 2
0
 /**
  * Handle an exception and display the exception report.
  *
  * @param \Exception $exception
  * @param boolean    $exit
  */
 public static function exception(\Exception $exception, $exit = true)
 {
     static::log($exception);
     ob_get_length() > 0 and ob_get_level() and ob_end_clean();
     $conf = Registry::get('conf');
     if (isset($conf['error']['debug_info']) && $conf['error']['debug_info'] === true) {
         echo static::format($exception);
         if ($exit) {
             exit;
         }
     }
     Header::clear();
     if ($exception instanceof \Pimf\Controller\Exception || $exception instanceof \Pimf\Resolver\Exception) {
         Event::first('404', array($exception));
         Header::sendNotFound(null, $exit);
     } else {
         Event::first('500', array($exception));
         Header::sendInternalServerError(null, $exit);
     }
 }
Exemplo n.º 3
0
 /**
  * @throws \RuntimeException
  */
 private function preventMultipleCaching()
 {
     if ($this->method != 'GET') {
         Header::clear();
         throw new \RuntimeException('HTTP cache headers can only take effect if request was sent via GET method!');
     }
     if (self::$cached === true) {
         Header::clear();
         throw new \RuntimeException('only one HTTP cache-control can be sent!');
     }
 }