Commit 8affa31a authored by Taylor Otwell's avatar Taylor Otwell

Added shortcut syntax for route handlers on named routes.

parent 75a9591c
...@@ -63,9 +63,9 @@ class Route { ...@@ -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 { ...@@ -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;
}
}
} }
\ 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