Added shortcut syntax for route handlers on named routes.

This commit is contained in:
Taylor Otwell 2011-08-05 09:18:40 -05:00
parent 75a9591c65
commit 8affa31a02
1 changed files with 17 additions and 2 deletions

View File

@ -63,9 +63,9 @@ public function call()
{ {
$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 @@ public function call()
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;
}
}
} }