path_offset = LIMB_HTTP_OFFSET_PATH; else $this->path_offset = $path_offset; if(is_null($base_path) && defined('LIMB_HTTP_BASE_PATH')) $this->base_path = LIMB_HTTP_BASE_PATH; else $this->base_path = $base_path; } function dispatch($request) { $routes = lmbToolkit :: instance()->getRoutes(); $uri = $request->getUri(); $uri->normalizePath(); $level = $this->_getHttpBasePathOffsetLevel($uri); $result = $routes->dispatch($uri->getPathFromLevel($level)); if($action = $request->get('action')) $result['action'] = $action; return $result; } protected function _getHttpBasePathOffsetLevel($uri) { if(!$this->path_offset) return 0; $base_path_uri = new lmbUri(rtrim($this->base_path, '/')); $base_path_uri->normalizePath(); $level = 1; while(($uri->getPathElement($level) == $base_path_uri->getPathElement($level)) && ($level < $base_path_uri->countPath())) { $level++; } return $level; } } ?>