From 64218976ae9f74b3b12395e59ace8de9088c747c Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 26 Oct 2017 10:01:30 +0100 Subject: [PATCH] Updating Travis CI config file and Cleaning the router --- .travis.yml | 6 ++++-- src/Routing/Router.php | 49 ++++++++++++------------------------------ 2 files changed, 18 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3191962..aa260ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,12 @@ sudo: false php: - 7.0 - 7.1 + - 7.2 - nightly matrix: allow_failures: + - php: 7.2 - php: nightly before_script: @@ -21,5 +23,5 @@ script: - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover after_script: - - if [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi + - if [ "$TRAVIS_PHP_VERSION" != "7.2" ] && [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi + - if [ "$TRAVIS_PHP_VERSION" != "7.2" ] && [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/src/Routing/Router.php b/src/Routing/Router.php index 7eb0919..bac612a 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -12,25 +12,6 @@ */ class Router { - /* ----------------------------------------------------------------- - | Getters & Setters - | ----------------------------------------------------------------- - */ - - /** - * Get active middlewares. - * - * @return Closure|array - */ - protected function getActiveMiddlewares() - { - return function() { - return array_keys(array_filter( - config('localization.route.middleware', []) - )); - }; - } - /* ----------------------------------------------------------------- | Route Methods | ----------------------------------------------------------------- @@ -39,14 +20,18 @@ protected function getActiveMiddlewares() /** * Create a route group with shared attributes. * - * @return Closure + * @return \Closure */ public function localizedGroup() { return function(Closure $callback, array $attributes = []) { + $activeMiddleware = array_keys(array_filter( + config('localization.route.middleware', []) + )); + $attributes = array_merge($attributes, [ - 'prefix' => localization()->setLocale(), - 'middleware' => $this->getActiveMiddlewares(), + 'prefix' => localization()->setLocale(), + 'middleware' => $activeMiddleware, ]); $this->group(array_filter($attributes), $callback); @@ -56,7 +41,7 @@ public function localizedGroup() /** * Register a new translated GET route with the router. * - * @return Closure|\Illuminate\Routing\Route + * @return \Closure|\Illuminate\Routing\Route */ public function transGet() { @@ -70,7 +55,7 @@ public function transGet() /** * Register a new translated POST route with the router. * - * @return Closure|\Illuminate\Routing\Route + * @return \Closure|\Illuminate\Routing\Route */ public function transPost() { @@ -84,7 +69,7 @@ public function transPost() /** * Register a new translated PUT route with the router. * - * @return Closure|\Illuminate\Routing\Route + * @return \Closure|\Illuminate\Routing\Route */ public function transPut() { @@ -98,7 +83,7 @@ public function transPut() /** * Register a new translated PATCH route with the router. * - * @return Closure|\Illuminate\Routing\Route + * @return \Closure|\Illuminate\Routing\Route */ public function transPatch() { @@ -112,7 +97,7 @@ public function transPatch() /** * Register a new translated DELETE route with the router. * - * @return Closure|\Illuminate\Routing\Route + * @return \Closure|\Illuminate\Routing\Route */ public function transDelete() { @@ -126,10 +111,7 @@ public function transDelete() /** * Register a new translated OPTIONS route with the router. * - * @return Closure|\Illuminate\Routing\Route - * @internal param string $trans - * @internal param array|Closure|string $action - * + * @return \Closure|\Illuminate\Routing\Route */ public function transOptions() { @@ -143,10 +125,7 @@ public function transOptions() /** * Register a new translated any route with the router. * - * @return Closure|\Illuminate\Routing\Route - * @internal param string $trans - * @internal param array|Closure|string $action - * + * @return \Closure|\Illuminate\Routing\Route */ public function transAny() {