overall code refactoring, comment improvement.

This commit is contained in:
Taylor Otwell
2011-06-17 00:02:24 -05:00
parent 5c275db6f4
commit 3408bb8492
10 changed files with 108 additions and 150 deletions

View File

@@ -40,26 +40,27 @@ class Route {
{
$response = null;
// --------------------------------------------------------------
// If the route just has a callback, call it.
// --------------------------------------------------------------
// ------------------------------------------------------------
// If the route value is just a function, all we have to do
// is execute the function! There are no filters to call.
// ------------------------------------------------------------
if (is_callable($this->route))
{
$response = call_user_func_array($this->route, $this->parameters);
}
// --------------------------------------------------------------
// The route value is an array. We'll need to evaluate it.
// --------------------------------------------------------------
// ------------------------------------------------------------
// If the route value is an array, we'll need to check it for
// any filters that may be attached.
// ------------------------------------------------------------
elseif (is_array($this->route))
{
// --------------------------------------------------------------
// Call the "before" route filters.
// --------------------------------------------------------------
$response = isset($this->route['before']) ? Filter::call($this->route['before'], array(), true) : null;
// --------------------------------------------------------------
// Call the route callback.
// --------------------------------------------------------------
// ------------------------------------------------------------
// We verify that the before filters did not return a response
// Before filters can override the request cycle to make things
// like authentication convenient to implement.
// ------------------------------------------------------------
if (is_null($response) and isset($this->route['do']))
{
$response = call_user_func_array($this->route['do'], $this->parameters);
@@ -68,9 +69,6 @@ class Route {
$response = Response::prepare($response);
// --------------------------------------------------------------
// Call the "after" route filters.
// --------------------------------------------------------------
if (is_array($this->route) and isset($this->route['after']))
{
Filter::call($this->route['after'], array($response));