Skip to content

Commit

Permalink
fix route list and kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 26, 2016
1 parent cb4e4eb commit abd85c9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/Illuminate/Foundation/Console/RouteListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,13 @@ protected function getControllerMiddlewareFromInstance($controller, $method)

$results = [];

foreach ($controller->getMiddleware() as $name => $options) {
if (! $method || ! $this->methodExcludedByOptions($method, $options)) {
$results[] = Arr::get($middleware, $name, $name);
foreach ($controller->getMiddleware() as $data) {
if (! is_string($data['middleware'])) {
continue;
}

if (! $method || ! $this->methodExcludedByOptions($method, $data['options'])) {
$results[] = Arr::get($middleware, $data['middleware'], $data['middleware']);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Foundation/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ public function terminate($request, $response)
);

foreach ($middlewares as $middleware) {
if (! is_string($middleware)) {
continue;
}

list($name, $parameters) = $this->parseMiddleware($middleware);

$instance = $this->app->make($name);
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Routing/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ abstract class Controller
/**
* Register middleware on the controller.
*
* @param array|string|\Closure $middlewares
* @param array|string|\Closure $middleware

This comment has been minimized.

Copy link
@tillkruss

tillkruss Aug 27, 2016

Collaborator

Thanks 😀

* @param array $options
* @return \Illuminate\Routing\ControllerMiddlewareOptions
*/
public function middleware($middlewares, array $options = [])
public function middleware($middleware, array $options = [])
{
foreach ((array) $middlewares as $middleware) {
foreach ((array) $middleware as $m) {
$this->middleware[] = [
'middleware' => $middleware,
'middleware' => $m,
'options' => &$options,
];
}
Expand Down
2 changes: 2 additions & 0 deletions src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -676,11 +676,13 @@ public function resolveMiddlewareClassName($name)
return $name;
} elseif (isset($map[$name]) && $map[$name] instanceof Closure) {
return $map[$name];

// If the middleware is the name of a middleware group, we will return the array
// of middlewares that belong to the group. This allows developers to group a
// set of middleware under single keys that can be conveniently referenced.
} elseif (isset($this->middlewareGroups[$name])) {
return $this->parseMiddlewareGroup($name);

// Finally, when the middleware is simply a string mapped to a class name the
// middleware name will get parsed into the full class name and parameters
// which may be run using the Pipeline which accepts this string format.
Expand Down

0 comments on commit abd85c9

Please sign in to comment.