From ecf0023f404bf679933c7cf1903028848c67097d Mon Sep 17 00:00:00 2001 From: Ralph Huwiler Date: Wed, 25 Jan 2017 09:00:56 +0100 Subject: [PATCH 1/3] Allow use of laravel 5.4 components --- composer.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 39b5614c0..3eff5e80c 100644 --- a/composer.json +++ b/composer.json @@ -17,19 +17,19 @@ "require": { "php": "^5.5.9 || ^7.0", "dingo/blueprint": "0.2.*", - "illuminate/routing": "5.1.* || 5.2.* || 5.3.*", - "illuminate/support": "5.1.* || 5.2.* || 5.3.*", + "illuminate/routing": "5.1.* || 5.2.* || 5.3.* || 5.4.*", + "illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.*", "league/fractal": ">=0.12.0" }, "require-dev": { - "illuminate/auth": "5.1.* || 5.2.* || 5.3.*", - "illuminate/cache": "5.1.* || 5.2.* || 5.3.*", - "illuminate/console": "5.1.* || 5.2.* || 5.3.*", - "illuminate/database": "5.1.* || 5.2.* || 5.3.*", - "illuminate/events": "5.1.* || 5.2.* || 5.3.*", - "illuminate/filesystem": "5.1.* || 5.2.* || 5.3.*", - "illuminate/log": "5.1.* || 5.2.* || 5.3.*", - "illuminate/pagination": "5.1.* || 5.2.* || 5.3.*", + "illuminate/auth": "5.1.* || 5.2.* || 5.3.* || 5.4.*", + "illuminate/cache": "5.1.* || 5.2.* || 5.3.* || 5.4.*", + "illuminate/console": "5.1.* || 5.2.* || 5.3.* || 5.4.*", + "illuminate/database": "5.1.* || 5.2.* || 5.3.* || 5.4.*", + "illuminate/events": "5.1.* || 5.2.* || 5.3.* || 5.4.*", + "illuminate/filesystem": "5.1.* || 5.2.* || 5.3.* || 5.4.*", + "illuminate/log": "5.1.* || 5.2.* || 5.3.* || 5.4.*", + "illuminate/pagination": "5.1.* || 5.2.* || 5.3.* || 5.4.*", "laravel/lumen-framework": "5.1.* || 5.2.*", "lucadegasperi/oauth2-server-laravel": "5.0.*", "mockery/mockery": "~0.9", From b130c1078c3a2137b74c34d7ccbc90775d75eedc Mon Sep 17 00:00:00 2001 From: Ralph Huwiler Date: Wed, 25 Jan 2017 10:39:33 +0100 Subject: [PATCH 2/3] Rename the router's middleware method to aliasMiddleware --- src/Provider/LaravelServiceProvider.php | 27 ++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Provider/LaravelServiceProvider.php b/src/Provider/LaravelServiceProvider.php index 1ba43f717..e7a22a9ae 100644 --- a/src/Provider/LaravelServiceProvider.php +++ b/src/Provider/LaravelServiceProvider.php @@ -39,9 +39,9 @@ public function boot() $this->updateRouterBindings(); }); - $this->app['router']->middleware('api.auth', Auth::class); - $this->app['router']->middleware('api.throttle', RateLimit::class); - $this->app['router']->middleware('api.controllers', PrepareController::class); + $this->addMiddlewareAlias('api.auth', Auth::class); + $this->addMiddlewareAlias('api.throttle', RateLimit::class); + $this->addMiddlewareAlias('api.controllers', PrepareController::class); } /** @@ -118,6 +118,27 @@ protected function addRequestMiddlewareToBeginning(Kernel $kernel) $kernel->prependMiddleware(Request::class); } + /** + * Register a short-hand name for a middleware. For Compatability + * with Laravel < 5.4 check if aliasMiddleware exists since this + * method has been renamed. + * + * @param $name + * @param $class + * + * @return void + */ + protected function addMiddlewareAlias($name, $class) + { + $router = $this->app['router']; + + if (method_exists($router, 'aliasMiddleware')) { + return $router->aliasMiddleware($name, $class); + } + + return $router->middleware($name, $class); + } + /** * Gather the application middleware besides this one so that we can send * our request through them, exactly how the developer wanted. From c4e29ade86d466cc85429da7f721b78fc0be443a Mon Sep 17 00:00:00 2001 From: Ralph Huwiler Date: Thu, 26 Jan 2017 08:17:06 +0100 Subject: [PATCH 3/3] added typehint to docblocks --- src/Provider/LaravelServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Provider/LaravelServiceProvider.php b/src/Provider/LaravelServiceProvider.php index e7a22a9ae..cca398e3e 100644 --- a/src/Provider/LaravelServiceProvider.php +++ b/src/Provider/LaravelServiceProvider.php @@ -123,8 +123,8 @@ protected function addRequestMiddlewareToBeginning(Kernel $kernel) * with Laravel < 5.4 check if aliasMiddleware exists since this * method has been renamed. * - * @param $name - * @param $class + * @param string $name + * @param string $class * * @return void */