public static function getAbsoluteRoute($path) { $url = UrlHelper::parse(UrlHelper::getRequestUrl()); $url['path'] = self::getRelativePath(self::getRoute($path)); $url['params'] = array(); return UrlHelper::build($url); }
/** * URL parser : load and parse the current URL * * The class will pass arguments values to any `$this->fromUrlParam($value)` method for the * parameter named `param`. * */ protected function _parseUrl() { $url_frgts = UrlHelper::parse($this->getUrl()); $route = array('all' => array()); if (!empty($url_frgts['params'])) { $frgts = array(); $url_args = $this->getArgumentsMap(); foreach ($url_frgts['params'] as $_var => $_val) { $_meth = 'fromUrl' . TextHelper::toCamelCase($_var); if (method_exists($this, $_meth)) { $_val = call_user_func_array(array($this, $_meth), array($_val)); } if (isset($url_args[$_var])) { $route[$url_args[$_var]] = $_val; } else { $route['all'][$_var] = $_val; } } } $this->setRouteParsed($route); }
/** * @return string */ public function buildUrl() { $url = UrlHelper::parse($this->getUrl()); $get = $this->getArguments(); if (!empty($get)) { foreach ($get as $arg => $val) { if ($this->getFlag() & self::REWRITE_SEGMENTS_QUERY) { $url['params'][$arg] = null; $path = '/' . $arg . '/'; if (1 === preg_match('#\\/' . $arg . '\\/[^\\/]*#i', $url['path'], $matches)) { $url['path'] = str_replace($matches[0], '/' . $arg . '/' . urlencode($val), $url['path']); } else { $url['path'] .= '/' . $arg . '/' . urlencode($val); } } else { $url['params'][$arg] = $val; } } } $user = $this->getAuthentication('user'); if (!empty($user)) { $url['user'] = $user; } $pwd = $this->getAuthentication('pwd'); if (!empty($pwd)) { $url['pass'] = $pwd; } $built_url = UrlHelper::build($url); return $built_url; }