/** * Execute the route and return the response. * * @param \Symfony\Component\HttpFoundation\Request $request * @return mixed */ public function run(Request $request) { $this->parsedParameters = null; // We will only call the router callable if no "before" middlewares returned // a response. If they do, we will consider that the response to requests // so that the request "lifecycle" will be easily halted for filtering. $response = $this->callBeforeFilters($request); if (!isset($response)) { $response = $this->callCallable(); } else { $fromFilter = true; } $response = $this->router->prepare($response, $request); // Once we have the "prepared" response, we will iterate through every after // filter and call each of them with the request and the response so they // can perform any final work that needs to be done after a route call. if (!isset($fromFilter)) { $this->callAfterFilters($request, $response); } return $response; }
/** * Process a controller action response. * * @param \Illuminate\Routing\Router $router * @param string $method * @param mixed $response * @return \Symfony\Component\HttpFoundation\Response */ protected function processResponse($router, $method, $response) { $request = $router->getRequest(); // The after filters give the developers one last chance to do any last minute // processing on the response. The response has already been converted to a // full Response object and will also be handed off to the after filters. $response = $router->prepare($response, $request); $this->callAfterFilters($router, $method, $response); return $response; }