diff --git a/laravel/laravel.php b/laravel/laravel.php index c15bd801..43ea0658 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -98,8 +98,7 @@ switch (Request::method()) $input = $_POST; break; - case 'PUT': - case 'DELETE': + default: if (Request::spoofed()) { $input = $_POST; diff --git a/laravel/routing/filter.php b/laravel/routing/filter.php index e76fe961..14b6e2e3 100644 --- a/laravel/routing/filter.php +++ b/laravel/routing/filter.php @@ -38,14 +38,17 @@ class Filter { * Filter::register('before', array('Class', 'method')); * * - * @param string $name - * @param Closure $callback + * @param string $name + * @param mixed $callback * @return void */ - public static function register($name, Closure $callback) + public static function register($name, $callback) { if (isset(static::$aliases[$name])) $name = static::$aliases[$name]; + // If the filter starts with "pattern: ", the filter is being setup to match on + // all requests that match a given pattern. This is nice for defining filters + // that handle all URIs beginning with "admin" for example. if (starts_with($name, 'pattern: ')) { foreach (explode(', ', substr($name, 9)) as $pattern) @@ -102,8 +105,7 @@ class Filter { // We will also go ahead and start the bundle for the developer. This allows // the developer to specify bundle filters on routes without starting the - // bundle manually, and performance is improved since the bundle is only - // started when needed. + // bundle manually, and performance is improved by lazy-loading. Bundle::start(Bundle::name($filter)); if ( ! isset(static::$filters[$filter])) continue; diff --git a/laravel/routing/route.php b/laravel/routing/route.php index 97a8f524..d926ac89 100644 --- a/laravel/routing/route.php +++ b/laravel/routing/route.php @@ -1,6 +1,7 @@ patterns()); + } + return array(new Filter_Collection($filters)); } + /** + * Get the pattern filters for the route. + * + * @return array + */ + protected function patterns() + { + // We will simply iterate through the registered patterns and + // check the URI pattern against the URI for the route and + // if they match we'll attach the filter. + foreach (Filter::$patterns as $pattern => $filter) + { + if (URI::is($pattern, $this->uri)) + { + $filters[] = $filter; + } + } + + return (array) $filters; + } + /** * Get the controller action delegate assigned to the route. * @@ -340,11 +370,11 @@ class Route { /** * Register a route filter. * - * @param string $name - * @param Closure $callback + * @param string $name + * @param mixed $callback * @return void */ - public static function filter($name, Closure $callback) + public static function filter($name, $callback) { Filter::register($name, $callback); } diff --git a/laravel/routing/router.php b/laravel/routing/router.php index aead9804..2f1573c9 100644 --- a/laravel/routing/router.php +++ b/laravel/routing/router.php @@ -31,6 +31,7 @@ class Router { 'POST' => array(), 'PUT' => array(), 'DELETE' => array(), + 'PATCH' => array(), 'HEAD' => array(), ); @@ -44,6 +45,7 @@ class Router { 'POST' => array(), 'PUT' => array(), 'DELETE' => array(), + 'PATCH' => array(), 'HEAD' => array(), );