예제 #1
0
 /**
  * Call a given route and return the route's response.
  *
  * @return Response
  */
 public function call()
 {
     // Since "before" filters can halt the request cycle, we will return
     // any response from the before filters. Allowing filters to halt the
     // request cycle makes tasks like authorization convenient.
     //
     // 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), it makes sense
     // to let the route handle the global filters. If the route uses
     // a controller, the controller will only call its own filters.
     $before = array_merge(array('before'), $this->filters('before'));
     $response = Filter::run($before, array(), true);
     if (is_null($response) and !is_null($response = $this->response())) {
         if ($response instanceof Delegate) {
             $response = Controller::call($response->destination, $this->parameters);
         }
     }
     if (!$response instanceof Response) {
         $response = new Response($response);
     }
     // Stringify the response. We need to force the response to be
     // stringed before closing the session, since the developer may
     // be using the session within their views, so we cannot age
     // the session data until the view is rendered.
     $response->content = $response->render();
     $filters = array_merge($this->filters('after'), array('after'));
     Filter::run($filters, array($response));
     return $response;
 }
예제 #2
0
 /**
  * Execute the route action and return the response.
  *
  * Unlike the "call" method, none of the attached filters will be run.
  *
  * @return mixed
  */
 public function response()
 {
     // If the action is a string, it is pointing the route to a controller
     // action, and we can just call the action and return its response.
     // We'll just pass the action off to the Controller class.
     $delegate = $this->delegate();
     if (!is_null($delegate)) {
         return Controller::call($delegate, $this->parameters);
     }
     // If the route does not have a delegate, then it must be a Closure
     // instance or have a Closure in its action array, so we will try
     // to locate the Closure and call it directly.
     $handler = $this->handler();
     if (!is_null($handler)) {
         return call_user_func_array($handler, $this->parameters);
     }
 }
예제 #3
0
 public function response()
 {
     $delegate = $this->delegate();
     if (!is_null($delegate)) {
         return Controller::call($delegate, $this->parameters);
     }
     $handler = $this->handler();
     if (!is_null($handler)) {
         return call_user_func_array($handler, $this->parameters);
     }
 }