Skip to content

Commit

Permalink
mod router, fix 404 callback for index
Browse files Browse the repository at this point in the history
  • Loading branch information
shayanderson committed Aug 31, 2017
1 parent e1ab43f commit 1008b1e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
36 changes: 25 additions & 11 deletions app/vendor/Eco/System/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ public function action($route_id)

if(method_exists($action[0], $action[1])) // verify method
{
if($route_id === '')
{
System::log()->debug('Mapped route detected for \'/\'', 'Eco');
}

System::hook(System::HOOK_MIDDLE);
$this->__routeCallback($route_id);
System::log()->debug('Calling route action \'' . $action[0] . '->'
Expand All @@ -304,6 +309,11 @@ public function action($route_id)
}
else if(is_callable($action)) // func
{
if($route_id === '')
{
System::log()->debug('Mapped route detected for \'/\'', 'Eco');
}

System::hook(System::HOOK_MIDDLE);
$this->__routeCallback($route_id);
System::log()->debug('Calling route action', 'Eco');
Expand Down Expand Up @@ -407,7 +417,6 @@ public function dispatch()
if(isset($request[0]) && empty($request[0])) // index action
{
$route_id = '';
System::log()->debug('Route detected for index', 'Eco');
}
else // non-index action
{
Expand Down Expand Up @@ -499,7 +508,7 @@ public function dispatch()

// set route
$route_id = $route;
System::log()->debug('Mapped route detected \'' . $route_id . '\'', 'Eco');
System::log()->debug('Mapped route detected for \'/' . $route_id . '\'', 'Eco');
break 2;
}
}
Expand All @@ -513,27 +522,32 @@ public function dispatch()
{
$route_id = null;

if($this->__404_callback !== null)
System::log()->debug('Failed to find route for request \''
. $this->request . '\'', 'Eco');
}

// call action
if(($route_id === null ? System::ERROR_NOT_FOUND : $this->action($route_id)) !== true)
{
if($route_id === '')
{
System::log()->debug('Failed to find route for request \'/\'', 'Eco');
}

if($this->__404_callback !== null) // attempt 404 callback
{
System::hook(System::HOOK_MIDDLE);

$handled = call_user_func($this->__404_callback, $this->request);

System::log()->debug('404 callback called');
System::log()->debug('404 callback called', 'Eco');

if($handled)
{
System::stop();
}
}

System::log()->debug('Failed to find route for request \''
. $this->request . '\'', 'Eco');
}

// call action
if(($route_id === null ? System::ERROR_NOT_FOUND : $this->action($route_id)) !== true)
{
System::error('Not found: \'' . $this->request . '\'', System::ERROR_NOT_FOUND, 'Eco');
}

Expand Down
2 changes: 1 addition & 1 deletion app/vendor/Eco/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
/**
* Eco version
*/
const ECO_VERSION = '1.3.3';
const ECO_VERSION = '1.3.4';

0 comments on commit 1008b1e

Please sign in to comment.