Flake\Util\Router\QuestionMarkRewrite::buildRoute PHP Method

buildRoute() static public method

static public buildRoute ( $sRoute, $aParams = [] )
    static function buildRoute($sRoute, $aParams = [])
    {
        #		$aParams = func_get_args();
        #		array_shift($aParams);	# Stripping $sRoute
        #		$sParams = implode("/", $aParams);
        $aParamsSegments = [];
        reset($aParams);
        foreach ($aParams as $sParamName => $sParamValue) {
            $aParamsSegments[] = rawurlencode($sParamName) . "/" . rawurlencode($sParamValue);
        }
        $sParams = implode("/", $aParamsSegments);
        if (trim($sParams) !== "") {
            $sParams .= "/";
        }
        if ($sRoute === "default" && empty($aParams)) {
            $sUrl = "/";
        } else {
            $sUrl = "/" . $sRoute . "/" . $sParams;
        }
        $sUriPath = self::getUriPath();
        if ($sUriPath === "" || $sUriPath === "/") {
            if ($sUrl !== "/") {
                $sUrl = "?" . $sUrl;
            }
        } else {
            if ($sUrl !== "/") {
                $sUrl = "/" . self::getUriPath() . "?" . $sUrl;
            } else {
                $sUrl = "/" . self::getUriPath();
            }
        }
        return $sUrl;
    }