Added shortcut syntax for route handlers on named routes.
This commit is contained in:
parent
75a9591c65
commit
8affa31a02
|
@ -63,9 +63,9 @@ public function call()
|
|||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue