added support for route filter parameters.
This commit is contained in:
parent
21592ec67f
commit
dfe3a04651
|
@ -134,7 +134,7 @@ protected function delegate(Route $route, $delegate)
|
|||
// an underscore are not publicly available.
|
||||
if (is_null($controller) or ($method == 'before' or strncmp($method, '_', 1) === 0))
|
||||
{
|
||||
return $this->container->resolve('laravel.response')->error('404');
|
||||
return Response::error('404');
|
||||
}
|
||||
|
||||
$controller->container = $this->container;
|
||||
|
@ -222,6 +222,16 @@ protected function filter($filters, $parameters = array(), $override = false)
|
|||
{
|
||||
foreach ((array) $filters as $filter)
|
||||
{
|
||||
// Parameters may be passed into routes by specifying the list of parameters after
|
||||
// a colon. If parameters are present, we will merge them into the parameter array
|
||||
// that was passed to the method and slice the parameters off of the filter string.
|
||||
if (($colon = strpos($filter, ':')) !== false)
|
||||
{
|
||||
$parameters = array_merge($parameters, explode(',', substr($filter, $colon + 1)));
|
||||
|
||||
$filter = substr($filter, 0, $colon);
|
||||
}
|
||||
|
||||
if ( ! isset($this->filters[$filter])) continue;
|
||||
|
||||
$response = call_user_func_array($this->filters[$filter], $parameters);
|
||||
|
|
|
@ -126,7 +126,9 @@ public function filters($name)
|
|||
{
|
||||
if (is_array($this->callback) and isset($this->callback[$name]))
|
||||
{
|
||||
return explode(', ', $this->callback[$name]);
|
||||
$filters = $this->callback[$name];
|
||||
|
||||
return (is_string($filters)) ? explode('|', $filters) : $filters;
|
||||
}
|
||||
|
||||
return array();
|
||||
|
|
Loading…
Reference in New Issue