fixed router ioc bug.

This commit is contained in:
Taylor Otwell
2011-11-11 23:36:31 -06:00
parent 0e8432e373
commit 32684fa12e
2 changed files with 40 additions and 0 deletions

View File

@@ -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))

View File

@@ -1,5 +1,7 @@
<?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;
}
}