/** * Call a given route and return the route's response. * * @return Response */ public function call() { // The route is responsible for running the global filters, and any // filters defined on the route itself, since all incoming requests // come through a route (either defined or ad-hoc). $response = Filter::run($this->filters('before'), array(), true); if (is_null($response)) { $response = $this->response(); } // We always return a Response instance from the route calls, so // we'll use the prepare method on the Response class to make // sure we have a valid Response instance. $response = Response::prepare($response); Filter::run($this->filters('after'), array($response)); return $response; }
public function call() { $response = Filter::run($this->filters('before'), array(), true); if (is_null($response)) { $response = $this->response(); } $response = Response::prepare($response); Filter::run($this->filters('after'), array(&$response)); return $response; }
/** * Execute a controller method with the given parameters. * * @param string $method * @param array $parameters * @return Response */ public function execute($method, $parameters = array()) { $filters = $this->filters('before', $method); // Again, as was the case with route closures, if the controller "before" // filters return a response, it will be considered the response to the // request and the controller method will not be used. $response = Filter::run($filters, array(), true); if (is_null($response)) { $this->before(); $response = $this->response($method, $parameters); } $response = Response::prepare($response); // The "after" function on the controller is simply a convenient hook // so the developer can work on the response before it's returned to // the browser. This is useful for templating, etc. $this->after($response); Filter::run($this->filters('after', $method), array($response)); return $response; }
public static function exception($exception, $trace = true) { static::log($exception); ob_get_level() and ob_end_clean(); $message = $exception->getMessage(); $file = $exception->getFile(); if (str_contains($exception->getFile(), 'eval()') and str_contains($exception->getFile(), 'laravel' . DS . 'view.php')) { $message = 'Error rendering view: [' . View::$last['name'] . ']' . PHP_EOL . PHP_EOL . $message; $file = View::$last['path']; } if (Config::get('error.detail')) { $response_body = "<html><h2>Unhandled Exception</h2>\n\t\t\t\t<h3>Message:</h3>\n\t\t\t\t<pre>" . $message . "</pre>\n\t\t\t\t<h3>Location:</h3>\n\t\t\t\t<pre>" . $file . " on line " . $exception->getLine() . "</pre>"; if ($trace) { $response_body .= "\n\t\t\t\t <h3>Stack Trace:</h3>\n\t\t\t\t <pre>" . $exception->getTraceAsString() . "</pre></html>"; } $response = Response::make($response_body, 500); } else { $response = Event::first('500'); $response = Response::prepare($response); } $response->render(); $response->send(); $response->foundation->finish(); exit(1); }