Bluz\Router\Router::urlCustom PHP Метод

urlCustom() защищенный Метод

Build URL by custom route
protected urlCustom ( string $module, string $controller, array $params ) : string
$module string
$controller string
$params array
Результат string
    protected function urlCustom($module, $controller, $params)
    {
        $url = $this->reverse[$module][$controller]['route'];
        $getParams = [];
        foreach ($params as $key => $value) {
            // sub-array as GET params
            if (is_array($value)) {
                $getParams[$key] = $value;
                continue;
            }
            $url = str_replace('{$' . $key . '}', $value, $url, $replaced);
            // if not replaced, setup param as GET
            if (!$replaced) {
                $getParams[$key] = $value;
            }
        }
        // clean optional params
        $url = preg_replace('/\\{\\$[a-z0-9-_]+\\}/i', '', $url);
        // clean regular expression (.*)
        $url = preg_replace('/\\(\\.\\*\\)/i', '', $url);
        // replace "//" with "/"
        $url = str_replace('//', '/', $url);
        if (!empty($getParams)) {
            $url .= '?' . http_build_query($getParams);
        }
        return $this->getBaseUrl() . ltrim($url, '/');
    }