Skip to content

Commit

Permalink
Always pass params to resolved target
Browse files Browse the repository at this point in the history
Altorouter seems to always populate the params key in its response to `match` so we would never fall into the `else` block.

Have refactored to make the code simpler and more consistent.
  • Loading branch information
joelambert committed Jul 21, 2017
1 parent 830ade2 commit 5b075da
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,8 @@ public function match(Request $request)
}

// Call the target with any resolved params
if (isset($altoRoute['params'])) {
$params = new RouteParams($altoRoute['params']);
$returnValue = call_user_func($altoRoute['target'], $params);
} else {
$returnValue = call_user_func($altoRoute['target']);
}
$params = new RouteParams($altoRoute['params']);
$returnValue = call_user_func($altoRoute['target'], $params);

// Ensure that we return an instance of a Response object
if (!($returnValue instanceof Response)) {
Expand Down

0 comments on commit 5b075da

Please sign in to comment.