Added shortcut syntax for route handlers on named routes.
This commit is contained in:
@@ -63,9 +63,9 @@ class Route {
|
|||||||
{
|
{
|
||||||
$response = isset($this->callback['before']) ? Filter::call($this->callback['before'], array(), true) : null;
|
$response = isset($this->callback['before']) ? Filter::call($this->callback['before'], array(), true) : null;
|
||||||
|
|
||||||
if (is_null($response) and isset($this->callback['do']))
|
if (is_null($response) and ! is_null($handler = $this->handler()))
|
||||||
{
|
{
|
||||||
$response = call_user_func_array($this->callback['do'], $this->parameters);
|
$response = call_user_func_array($handler, $this->parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,4 +79,19 @@ class Route {
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the route function from the route.
|
||||||
|
*
|
||||||
|
* @return Closure
|
||||||
|
*/
|
||||||
|
private function handler()
|
||||||
|
{
|
||||||
|
if (isset($this->callback['do'])) return $this->callback['do'];
|
||||||
|
|
||||||
|
foreach ($this->callback as $value)
|
||||||
|
{
|
||||||
|
if (is_callable($value)) return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user