Skip to content

Commit

Permalink
Merge pull request #110 from ARCANEDEV/patch-1
Browse files Browse the repository at this point in the history
Updating Travis CI config file and Cleaning the router
  • Loading branch information
arcanedev-maroc authored Oct 26, 2017
2 parents d8c3797 + 6421897 commit a54affc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ sudo: false
php:
- 7.0
- 7.1
- 7.2
- nightly

matrix:
allow_failures:
- php: 7.2
- php: nightly

before_script:
Expand All @@ -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
49 changes: 14 additions & 35 deletions src/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
| -----------------------------------------------------------------
Expand All @@ -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);
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand Down

0 comments on commit a54affc

Please sign in to comment.