/** * Route the request * @return array array($controller, $action, $params); */ public static function route() { $request = rtRequest::getInstance(); // match the routes foreach (self::$_routes as $route) { list($rule, $tokens) = self::compile_route($route[1]); if (preg_match($rule, $request->getParameter('request_path_info'), $matches) == 1) { // fill the request foreach ($tokens as $i => $token) { $request->setParameter($token, $matches[$i + 1]); } // fill with params if (isset($route[2]) && is_array($route)) { foreach ($route[2] as $key => $value) { $request->setParameter($key, $value); } } rtLogger::log(ROUTE_LOG, "matched route: {$route[1]}"); return; } // Log matching rtLogger::log(ROUTE_LOG, "mismatch route: {$route[1]}"); } // no route match throw new RouterExecption('No route match:' . $_SERVER['REQUEST_URI']); }
public function process_response() { if (!rtConfig::get('enable_toolbar', false)) { return; } $params = array('logs' => rtLogger::getLogs()); $params = array_merge($params, rtController::getMagicViewVars()); list($tpl, $view_class) = findTemplateFileName(rtConfig::get('rt_core_dir') . DS . 'default' . DS . 'toolbar'); $toolbar = new $view_class($tpl, $params); $response = rtResponse::getInstance(); $new_body = str_replace('</body>', $toolbar->getOutput() . '</body>', $response->getBody()); $response->setBody($new_body); }