/** * The function initializes router feature. * * @static * @access private */ private static function initRoute() { Route::run(Request::get('REQUEST_URI', '/', 'SERVER')); $host = strtolower(Config::get('host')); if ($host) { $sub = trim(str_replace($host, '', preg_replace('/^www\\./', '', strtolower(Runtime::get('HTTP_HOST')))), '.'); if (!$sub) { $sub = 'www'; } Runtime::set('HTTP_SUBDOMAIN', $sub); } $controller = 0; $args = array(); $path = Route::get(); Runtime::set('REQUEST_URI', '/' . implode('/', $path)); if (!is_array($path)) { $path = ltrim('/', explode('/', $path)); } $values = $path; $link = '/'; for ($i = 0; $i < count($values); $i++) { $arr = array_slice($values, 0, count($values) - $i); $link = '/' . implode('/', $arr); $controller = Route::getController($link); if ($controller) { $args = array_slice($values, count($values) - $i); break; } } if (!$controller) { $controller = Route::getController('/'); $args = $values; } if (!$controller) { echo "No controller found: /" . implode('/', $path) . "\n"; exit; } Runtime::set('ROUTING_CONTROLLER', $controller); Runtime::set('ROUTING_ROUTER', Route::getRouter($link)); Runtime::set('ROUTING_ARGUMENTS', $args); }