Skip to content

Commit 924394d

Browse files
authored
[9.x] Add resolveMiddleware() method to Router (#40165)
1 parent e076a56 commit 924394d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/Illuminate/Routing/Router.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,13 +705,23 @@ protected function runRouteWithinStack(Route $route, Request $request)
705705
*/
706706
public function gatherRouteMiddleware(Route $route)
707707
{
708-
$computedMiddleware = $route->gatherMiddleware();
708+
return $this->resolveMiddleware($route->gatherMiddleware(), $route->excludedMiddleware());
709+
}
709710

710-
$excluded = collect($route->excludedMiddleware())->map(function ($name) {
711+
/**
712+
* Resolve a flat array of middleware classes from the provided array.
713+
*
714+
* @param array $middleware
715+
* @param array $excluded
716+
* @return array
717+
*/
718+
public function resolveMiddleware(array $middleware, array $excluded = [])
719+
{
720+
$excluded = collect($excluded)->map(function ($name) {
711721
return (array) MiddlewareNameResolver::resolve($name, $this->middleware, $this->middlewareGroups);
712722
})->flatten()->values()->all();
713723

714-
$middleware = collect($computedMiddleware)->map(function ($name) {
724+
$middleware = collect($middleware)->map(function ($name) {
715725
return (array) MiddlewareNameResolver::resolve($name, $this->middleware, $this->middlewareGroups);
716726
})->flatten()->reject(function ($name) use ($excluded) {
717727
if (empty($excluded)) {

0 commit comments

Comments
 (0)