Merge pull request #854 from jasonlewis/feature/pattern-filters
Allow filter patterns to supply a name and callback as an easier alternative.
This commit is contained in:
commit
990f10f6de
|
@ -152,6 +152,15 @@ #### Defining a URI pattern based filter:
|
|||
|
||||
Route::filter('pattern: admin/*', 'auth');
|
||||
|
||||
Optionally you can register filters directly when attaching filters to a given URI by supplying an array with the name of the filter and a callback.
|
||||
|
||||
#### Defining a filter and URI pattern based filter in one:
|
||||
|
||||
Route::filter('pattern: admin/*', array('name' => 'auth', function()
|
||||
{
|
||||
//
|
||||
}));
|
||||
|
||||
<a name="global-filters"></a>
|
||||
## Global Filters
|
||||
|
||||
|
|
|
@ -213,6 +213,15 @@ protected function patterns()
|
|||
{
|
||||
if (Str::is($pattern, $this->uri))
|
||||
{
|
||||
// If the filter provided is an array then we need to register
|
||||
// the filter before we can assign it to the route.
|
||||
if (is_array($filter))
|
||||
{
|
||||
list($filter, $callback) = array_values($filter);
|
||||
|
||||
Filter::register($filter, $callback);
|
||||
}
|
||||
|
||||
$filters[] = $filter;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue