Skip to content

Commit 426697c

Browse files
committed
allow after and close filters to be called even when before filter returns response.
1 parent b63d5ea commit 426697c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Illuminate/Routing/Router.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -774,16 +774,22 @@ public function dispatch(Request $request)
774774

775775
if ( ! is_null($response))
776776
{
777-
return $this->prepare($response, $request);
777+
$response = $this->prepare($response, $request);
778778
}
779779

780-
$this->currentRoute = $route = $this->findRoute($request);
781-
782780
// Once we have the route, we can just run it to get the responses, which will
783781
// always be instances of the Response class. Once we have the responses we
784782
// will execute the global "after" middlewares to finish off the request.
785-
$response = $route->run($request);
783+
else
784+
{
785+
$this->currentRoute = $route = $this->findRoute($request);
786+
787+
$response = $route->run($request);
788+
}
786789

790+
// Finally after the route has been run we can call the after and close global
791+
// filters for the request, giving a chance for any final processing to get
792+
// done before the response gets returned back to the user's web browser.
787793
$this->callAfterFilter($request, $response);
788794

789795
return $response;

0 commit comments

Comments
 (0)