From 1008b1eba4b2e93e305856eeb8439b60dc7eab9b Mon Sep 17 00:00:00 2001 From: Shay Anderson Date: Thu, 31 Aug 2017 17:17:49 -0400 Subject: [PATCH] mod router, fix 404 callback for index --- app/vendor/Eco/System/Router.php | 36 ++++++++++++++++++++++---------- app/vendor/Eco/version.php | 2 +- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/app/vendor/Eco/System/Router.php b/app/vendor/Eco/System/Router.php index 71aa161..c20ae87 100644 --- a/app/vendor/Eco/System/Router.php +++ b/app/vendor/Eco/System/Router.php @@ -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] . '->' @@ -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'); @@ -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 { @@ -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; } } @@ -513,13 +522,25 @@ 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) { @@ -527,13 +548,6 @@ public function dispatch() } } - 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'); } diff --git a/app/vendor/Eco/version.php b/app/vendor/Eco/version.php index 156f56a..93b3969 100644 --- a/app/vendor/Eco/version.php +++ b/app/vendor/Eco/version.php @@ -11,4 +11,4 @@ /** * Eco version */ -const ECO_VERSION = '1.3.3'; \ No newline at end of file +const ECO_VERSION = '1.3.4'; \ No newline at end of file