Skip to content

Commit

Permalink
Set the controller name on the action array when callable array synta…
Browse files Browse the repository at this point in the history
…x is used
  • Loading branch information
clemir committed Jun 5, 2018
1 parent 17c4c0f commit 72842ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Routing/RouteAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public static function parse($uri, $action)
if (is_callable($action)) {
if (is_array($action)) {
$action = $action[0].'@'.$action[1];
return [
'uses' => $action,
'controller' => $action
];
}

return ['uses' => $action];
Expand Down
2 changes: 2 additions & 0 deletions tests/Routing/RoutingRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,8 @@ public function testControllerRoutingArrayCallable()
$this->assertEquals(0, $_SERVER['route.test.controller.middleware.parameters.one']);
$this->assertEquals(['foo', 'bar'], $_SERVER['route.test.controller.middleware.parameters.two']);
$this->assertFalse(isset($_SERVER['route.test.controller.except.middleware']));
$action = $router->getRoutes()->getRoutes()[0]->getAction()['controller'];
$this->assertEquals('Illuminate\Tests\Routing\RouteTestControllerStub@index', $action);
}

public function testCallableControllerRouting()
Expand Down

0 comments on commit 72842ff

Please sign in to comment.