From cc6012140ed633be7ed4e39b1de8007871f81c32 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 22 Jun 2016 08:23:51 -0500 Subject: [PATCH] fixing a few things. cleanup --- .../Foundation/Console/RouteListCommand.php | 2 -- src/Illuminate/Routing/Controller.php | 28 ------------------- .../Routing/ControllerDispatcher.php | 26 ++--------------- src/Illuminate/Routing/Route.php | 20 +++++++------ 4 files changed, 14 insertions(+), 62 deletions(-) diff --git a/src/Illuminate/Foundation/Console/RouteListCommand.php b/src/Illuminate/Foundation/Console/RouteListCommand.php index d06db108806e..c03f48353bfc 100644 --- a/src/Illuminate/Foundation/Console/RouteListCommand.php +++ b/src/Illuminate/Foundation/Console/RouteListCommand.php @@ -157,8 +157,6 @@ protected function getMiddleware($route) */ protected function getControllerMiddleware($actionName) { - Controller::setRouter($this->laravel['router']); - $segments = explode('@', $actionName); return $this->getControllerMiddlewareFromInstance( diff --git a/src/Illuminate/Routing/Controller.php b/src/Illuminate/Routing/Controller.php index 8e3e47f7c908..1175c278d355 100644 --- a/src/Illuminate/Routing/Controller.php +++ b/src/Illuminate/Routing/Controller.php @@ -14,13 +14,6 @@ abstract class Controller */ protected $middleware = []; - /** - * The router instance. - * - * @var \Illuminate\Routing\Router - */ - protected static $router; - /** * Register middleware on the controller. * @@ -47,27 +40,6 @@ public function getMiddleware() return $this->middleware; } - /** - * Get the router instance. - * - * @return \Illuminate\Routing\Router - */ - public static function getRouter() - { - return static::$router; - } - - /** - * Set the router instance. - * - * @param \Illuminate\Routing\Router $router - * @return void - */ - public static function setRouter(Router $router) - { - static::$router = $router; - } - /** * Execute an action on the controller. * diff --git a/src/Illuminate/Routing/ControllerDispatcher.php b/src/Illuminate/Routing/ControllerDispatcher.php index 4e5773e1f260..aebfdc83c17f 100644 --- a/src/Illuminate/Routing/ControllerDispatcher.php +++ b/src/Illuminate/Routing/ControllerDispatcher.php @@ -6,24 +6,6 @@ class ControllerDispatcher { use RouteDependencyResolverTrait; - /** - * The router instance. - * - * @var \Illuminate\Routing\Router - */ - protected $router; - - /** - * Create a new controller dispatcher instance. - * - * @param \Illuminate\Routing\Router $router - * @return void - */ - public function __construct(Router $router) - { - $this->router = $router; - } - /** * Dispatch a request to a given controller and method. * @@ -34,20 +16,18 @@ public function __construct(Router $router) */ public function dispatch(Route $route, $controller, $method) { - Controller::setRouter($this->router); - - return $this->call($controller, $route, $method); + return $this->call($route, $controller, $method); } /** * Call the given controller instance method. * - * @param \Illuminate\Routing\Controller $controller * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Routing\Controller $controller * @param string $method * @return mixed */ - protected function call($controller, $route, $method) + protected function call($route, $controller, $method) { $parameters = $this->resolveClassMethodDependencies( $route->parametersWithoutNulls(), $controller, $method diff --git a/src/Illuminate/Routing/Route.php b/src/Illuminate/Routing/Route.php index 02f93fdf30d8..990ca2bb0b58 100755 --- a/src/Illuminate/Routing/Route.php +++ b/src/Illuminate/Routing/Route.php @@ -43,6 +43,13 @@ class Route */ protected $action; + /** + * The controller instance. + * + * @var mixed + */ + protected $controller; + /** * The default values for the route. * @@ -85,13 +92,6 @@ class Route */ protected $router; - /** - * The controller instance. - * - * @var mixed - */ - protected $controller; - /** * The container instance used by the route. * @@ -183,7 +183,7 @@ protected function runCallable() */ protected function runController() { - return (new ControllerDispatcher($this->router))->dispatch( + return (new ControllerDispatcher)->dispatch( $this, $this->getController(), $this->getControllerMethod() ); } @@ -310,7 +310,9 @@ public function controllerMiddleware() return []; } - return ControllerDispatcher::getMiddleware($this->getController(), $this->getControllerMethod()); + return ControllerDispatcher::getMiddleware( + $this->getController(), $this->getControllerMethod() + ); } /**