Skip to content

Commit 434b481

Browse files
committed
Pull the middleware from the controller correctly depending upon the installation in use.
Signed-off-by: Jason Lewis <[email protected]>
1 parent d1b7fad commit 434b481

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Routing/Route.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Http\Request;
99
use Illuminate\Container\Container;
1010
use Dingo\Api\Contract\Routing\Adapter;
11+
use Laravel\Lumen\Routing\Controller as LumenController;
1112

1213
class Route
1314
{
@@ -194,7 +195,15 @@ protected function mergeControllerProperties()
194195

195196
$controller = $this->getControllerInstance();
196197

197-
$this->middleware = array_merge($this->middleware, $controller->getMiddleware());
198+
$controllerMiddleware = [];
199+
200+
if (method_exists($controller, 'getMiddleware')) {
201+
$controllerMiddleware = $controller->getMiddleware();
202+
} elseif (method_exists($controller, 'getMiddlewareForMethod')) {
203+
$controllerMiddleware = $controller->getMiddlewareForMethod($this->controllerMethod);
204+
}
205+
206+
$this->middleware = array_merge($this->middleware, $controllerMiddleware);
198207

199208
if ($property = $this->findControllerPropertyOptions('throttles')) {
200209
$this->throttle = $property['class'];

0 commit comments

Comments
 (0)