From ac810f8597d20f7215605afd4c0337c34f8e38ec Mon Sep 17 00:00:00 2001 From: Jason Lewis Date: Sun, 24 Jun 2012 19:28:53 +0930 Subject: [PATCH 1/2] Allow filter patterns to supply a name and callback as an easier alternative. Signed-off-by: Jason Lewis --- laravel/routing/route.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/laravel/routing/route.php b/laravel/routing/route.php index 73b79521..b63bdc32 100644 --- a/laravel/routing/route.php +++ b/laravel/routing/route.php @@ -213,6 +213,15 @@ class Route { { 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; } } From cea48d4fe5e379c907ccb7cd9b2580e3a227445a Mon Sep 17 00:00:00 2001 From: Jason Lewis Date: Sun, 24 Jun 2012 19:37:08 +0930 Subject: [PATCH 2/2] Updated the documentation. Signed-off-by: Jason Lewis --- laravel/documentation/routing.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/laravel/documentation/routing.md b/laravel/documentation/routing.md index 18c90671..d10be6b1 100644 --- a/laravel/documentation/routing.md +++ b/laravel/documentation/routing.md @@ -152,6 +152,15 @@ Sometimes you may want to attach a filter to all requests that begin with a give 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() + { + // + })); + ## Global Filters