Skip to content

Commit

Permalink
Revert changes to controller middleware (#40675)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints authored Jan 27, 2022
1 parent f64cfa3 commit b4c421d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 120 deletions.
8 changes: 0 additions & 8 deletions src/Illuminate/Routing/Contracts/ControllerDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,4 @@ public function dispatch(Route $route, $controller, $method);
* @return array
*/
public function getMiddleware($controller, $method);

/**
* Determine if the dispatcher should attempt to gather middleware from a controller.
*
* @param string $controller
* @return bool
*/
public function shouldGatherMiddleware($controller);
}
15 changes: 4 additions & 11 deletions src/Illuminate/Routing/ControllerDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,15 @@ public function dispatch(Route $route, $controller, $method)
*/
public function getMiddleware($controller, $method)
{
if (! method_exists($controller, 'getMiddleware')) {
return [];
}

return collect($controller->getMiddleware())->reject(function ($data) use ($method) {
return static::methodExcludedByOptions($method, $data['options']);
})->pluck('middleware')->all();
}

/**
* Determine if the dispatcher should attempt to gather middleware from a controller.
*
* @param string $controller
* @return bool
*/
public function shouldGatherMiddleware($controller)
{
return method_exists($controller, 'getMiddleware');
}

/**
* Determine if the given options exclude a particular method.
*
Expand Down
29 changes: 3 additions & 26 deletions src/Illuminate/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ class Route
*/
public $controller;

/**
* The controller instance class name.
*
* @var string
*/
public $controllerClass;

/**
* The default values for the route.
*
Expand Down Expand Up @@ -277,24 +270,12 @@ protected function runController()
public function getController()
{
if (! $this->controller) {
$this->controller = $this->container->make($this->getControllerClass());
}

return $this->controller;
}
$class = $this->parseControllerCallback()[0];

/**
* Get the controller class reference for the route.
*
* @return string
*/
public function getControllerClass()
{
if (! $this->controllerClass) {
$this->controllerClass = ltrim($this->parseControllerCallback()[0], '\\');
$this->controller = $this->container->make(ltrim($class, '\\'));
}

return $this->controllerClass;
return $this->controller;
}

/**
Expand Down Expand Up @@ -1086,10 +1067,6 @@ public function controllerMiddleware()
return [];
}

if (! $this->controllerDispatcher()->shouldGatherMiddleware($this->getControllerClass())) {
return [];
}

return $this->controllerDispatcher()->getMiddleware(
$this->getController(), $this->getControllerMethod()
);
Expand Down
75 changes: 0 additions & 75 deletions tests/Integration/Routing/RoutingMiddlewareTest.php

This file was deleted.

0 comments on commit b4c421d

Please sign in to comment.