Esempio n. 1
0
 public function __toString()
 {
     try {
         return $this->render();
     } catch (Exception $e) {
         $error_response = Kohana_exception::handler($e);
         return $error_response;
     }
 }
Esempio n. 2
0
 public function doIncludeViews($text)
 {
     if (preg_match_all('/{{([^\\s{}]++)}}/', $text, $matches, PREG_SET_ORDER)) {
         $replace = array();
         $replace = array();
         foreach ($matches as $set) {
             list($search, $view) = $set;
             try {
                 $replace[$search] = View::factory($view)->render();
             } catch (Exception $e) {
                 ob_start();
                 // Capture the exception handler output and insert it instead
                 Kohana_exception::handler($e);
                 $replace[$search] = ob_get_clean();
             }
         }
         $text = strtr($text, $replace);
     }
     return $text;
 }
Esempio n. 3
0
 /**
  * Magic method, returns the output of [View::render].
  *
  * @return  string
  * @uses    View::render
  */
 public function __toString()
 {
     try {
         return $this->render();
     } catch (Exception $e) {
         /**
          * Display the exception message.
          *
          * We use this method here because it's impossible to throw and
          * exception from __toString().
          */
         $error_response = Kohana_exception::_handler($e);
         return $error_response->body();
     }
 }
 public function doIncludeViews($text)
 {
     if (preg_match_all('/{{([^\\s{}]++)}}/', $text, $matches, PREG_SET_ORDER)) {
         $replace = array();
         foreach ($matches as $set) {
             list($search, $view) = $set;
             if (Kohana::find_file('views', $view)) {
                 try {
                     $replace[$search] = View::factory($view)->render();
                 } catch (Exception $e) {
                     /**
                      * Capture the exception handler output and insert it instead.
                      *
                      * NOTE: Is this really the correct way to handle an exception?
                      */
                     $response = Kohana_exception::_handler($e);
                     $replace[$search] = $response->body();
                 }
             }
         }
         $text = strtr($text, $replace);
     }
     return $text;
 }