Commit 74220510 authored by Nicolas Widart's avatar Nicolas Widart

Using the base filter class from the core module

parent 47a54a90
<?php namespace Modules\Workshop\Http\Filters;
class PermissionFilter {
public function filter()
{
//
}
}
\ No newline at end of file
...@@ -18,7 +18,9 @@ class WorkshopServiceProvider extends ServiceProvider ...@@ -18,7 +18,9 @@ class WorkshopServiceProvider extends ServiceProvider
* @var array * @var array
*/ */
protected $filters = [ protected $filters = [
'permissions' => 'PermissionFilter' 'Core' => [
'permissions' => 'PermissionFilter'
]
]; ];
/** /**
...@@ -29,10 +31,12 @@ class WorkshopServiceProvider extends ServiceProvider ...@@ -29,10 +31,12 @@ class WorkshopServiceProvider extends ServiceProvider
*/ */
public function registerFilters(Router $router) public function registerFilters(Router $router)
{ {
foreach ($this->filters as $name => $filter) { foreach ($this->filters as $module => $filters) {
$class = 'Modules\\Workshop\\Http\\Filters\\' . $filter; foreach ($filters as $name => $filter) {
$class = "Modules\\{$module}\\Http\\Filters\\{$filter}";
$router->filter($name, $class); $router->filter($name, $class);
}
} }
} }
...@@ -43,11 +47,9 @@ class WorkshopServiceProvider extends ServiceProvider ...@@ -43,11 +47,9 @@ class WorkshopServiceProvider extends ServiceProvider
*/ */
public function register() public function register()
{ {
$this->app->booted( $this->app->booted(function ($app) {
function ($app) { $this->registerFilters($app['router']);
$this->registerFilters($app['router']); });
}
);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment