Skip to content

Commit

Permalink
Move middleware detection method into helper class
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebronner committed Feb 21, 2016
1 parent 2526bf6 commit 1b348e2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"require": {
"php": ">=5.5.0",
"illuminate/support": "~5.1",
"illuminate/routing": "^5.1"
"illuminate/routing": "~5.1"
},
"require-dev": {
"phpunit/phpunit": "4.*"
Expand Down
23 changes: 23 additions & 0 deletions src/Helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php namespace GeneaLabs\LaravelCaffeine;

use Illuminate\Support\Facades\Route;

class Helper
{
public function routeHasMiddlewareGroup($group)
{
$routes = Route::getRoutes()->getRoutes();

foreach ($routes as $route) {
$actions = (array) $route->getAction();

if (array_key_exists('middleware', $actions)
&& in_array($group, (array) $actions['middleware'])
) {
return true;
}
}

return false;
}
}

0 comments on commit 1b348e2

Please sign in to comment.