fixed router ioc bug.
This commit is contained in:
@@ -177,6 +177,8 @@ $loader = new Routing\Loader(APP_PATH, ROUTE_PATH);
|
|||||||
|
|
||||||
$router = new Routing\Router($loader, CONTROLLER_PATH);
|
$router = new Routing\Router($loader, CONTROLLER_PATH);
|
||||||
|
|
||||||
|
IoC::instance('laravel.routing.router', $router);
|
||||||
|
|
||||||
Request::$route = $router->route($method, $uri);
|
Request::$route = $router->route($method, $uri);
|
||||||
|
|
||||||
if ( ! is_null(Request::$route))
|
if ( ! is_null(Request::$route))
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php namespace Laravel\Routing;
|
<?php namespace Laravel\Routing;
|
||||||
|
|
||||||
|
use Laravel\Request;
|
||||||
|
|
||||||
class Filter {
|
class Filter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,6 +100,13 @@ class Filter_Collection {
|
|||||||
*/
|
*/
|
||||||
public $filters = array();
|
public $filters = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The HTTP methods for which the filter applies.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $methods = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new filter collection instance.
|
* Create a new filter collection instance.
|
||||||
*
|
*
|
||||||
@@ -128,6 +137,11 @@ class Filter_Collection {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($this->methods) > 0 and ! in_array(strtolower(Request::method()), $this->methods))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,4 +192,28 @@ class Filter_Collection {
|
|||||||
return $this;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user