Commit 32684fa1 authored by Taylor Otwell's avatar Taylor Otwell

fixed router ioc bug.

parent 0e8432e3
......@@ -177,6 +177,8 @@ $loader = new Routing\Loader(APP_PATH, ROUTE_PATH);
$router = new Routing\Router($loader, CONTROLLER_PATH);
IoC::instance('laravel.routing.router', $router);
Request::$route = $router->route($method, $uri);
if ( ! is_null(Request::$route))
......
<?php namespace Laravel\Routing;
use Laravel\Request;
class Filter {
/**
......@@ -98,6 +100,13 @@ class Filter_Collection {
*/
public $filters = array();
/**
* The HTTP methods for which the filter applies.
*
* @var array
*/
public $methods = array();
/**
* Create a new filter collection instance.
*
......@@ -128,6 +137,11 @@ class Filter_Collection {
return false;
}
if (count($this->methods) > 0 and ! in_array(strtolower(Request::method()), $this->methods))
{
return false;
}
return true;
}
......@@ -178,4 +192,28 @@ class Filter_Collection {
return $this;
}
/**
* Set the HTTP methods for which the filter applies.
*
* Since some filters, such as the CSRF filter, only make sense in a POST
* request context, this method allows you to limit which HTTP methods
* the filter will apply to.
*
* <code>
* // Specify that a filter only applies on POST requests
* $this->filter('before', 'csrf')->on('post');
*
* // Specify that a filter applies for multiple HTTP request methods
* $this->filter('before', 'csrf')->on(array('post', 'put'));
* </code>
*
* @param array $methods
* @return Filter_Collection
*/
public function on($methods)
{
$this->methods = array_map('strtolower', (array) $methods);
return $this;
}
}
\ No newline at end of file
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