Skip to content

Commit

Permalink
Updated router - add action to $args
Browse files Browse the repository at this point in the history
  • Loading branch information
rakshazi committed May 13, 2019
1 parent 8104ca1 commit 5d937c0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Router.php
Expand Up @@ -26,7 +26,9 @@ public function __invoke(\Slim\App $app): void
foreach ($routes as $name => $route) {
$methods = $route['methods'] ?? ['GET'];
$pattern = $route['pattern'] ?? '';
$callable = function (Request $request, Response $response, array $args = []) use ($controller, $route) {
$callable = function (Request $request, Response $response, array $args = []) use ($controller, $name) {
$args['action'] = $name;

return $this['controller']($controller)->__invoke($request, $response, $args);
};
$this->map($methods, $pattern, $callable)->setName(('index' === $controller ? '' : $controller).'-'.$name);
Expand Down

0 comments on commit 5d937c0

Please sign in to comment.