From 3d1a44028acdf566c673d41450c1c0329751b1ce Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 12 Feb 2012 16:41:03 -0600 Subject: [PATCH] added route::share method. --- laravel/routing/route.php | 12 ++++++++++++ laravel/routing/router.php | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/laravel/routing/route.php b/laravel/routing/route.php index 8a4f27c0..128e936d 100644 --- a/laravel/routing/route.php +++ b/laravel/routing/route.php @@ -332,6 +332,18 @@ public static function group($attributes, Closure $callback) Router::group($attributes, $callback); } + /** + * Register many request URIs to a single action. + * + * @param array $routes + * @param mixed $action + * @return void + */ + public static function share($routes, $action) + { + Router::share($routes, $action); + } + /** * Register a HTTPS route with the router. * diff --git a/laravel/routing/router.php b/laravel/routing/router.php index 0c643085..6991f1f4 100644 --- a/laravel/routing/router.php +++ b/laravel/routing/router.php @@ -100,6 +100,26 @@ public static function secure($method, $route, $action) static::register($method, $route, $action); } + /** + * Register many request URIs to a single action. + * + * + * // Register a group of URIs for an action + * Router::share(array('GET', '/'), array('POST', '/'), 'home@index'); + * + * + * @param array $routes + * @param mixed $action + * @return void + */ + public static function share($routes, $action) + { + foreach ($routes as $route) + { + static::register($route[0], $route[1], $action); + } + } + /** * Register a group of routes that share attributes. *