kernel/core/UrlManager.php
public function getUrl(string $sCode, array $aParams = array()) : string
    {
        if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) {

            foreach (Config::get('route') as $sHost => $oHost) {

                if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST'])
                    || (strstr($sHost, '/')
                    && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) {

                    if (strstr($sHost, '/')
                        && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) {

                        $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost);
                    }

                    if (isset($oHost->routes)) {

                        foreach($oHost->routes as $sKey => $oRoute) {

                            if ($sKey === $sCode) {

                                $sRoute = $this->_sBaseUri.$oRoute->route;

                                if (isset($oRoute->constraints)) {

                                    foreach ($oRoute->constraints as $sName => $sType) {

                                        if (!isset($aParams[$sName])) { $aParams[$sName] = ''; }

                                        if (preg_match('#'.$sType.'#', $aParams[$sName])) {

                                            if ($aParams[$sName]) { $sRoute = str_replace('[/:'.$sName.']', '/'.$aParams[$sName], $sRoute); } else { $sRoute = str_replace('[/:'.$sName.']', '', $sRoute); }
                                            $sRoute = str_replace('[:'.$sName.']', $aParams[$sName], $sRoute);
                                            continue;
                                        } else if (isset($oRoute->defaults_constraints)
                                            && isset($oRoute->defaults_constraints->{$sName})
                                            && preg_match('#'.$sType.'#', $oRoute->defaults_constraints->{$sName})) {

                                            continue;
                                        }

                                        throw new \Exception('For the route '.$sCode.' the parameter '.$sName.' is not good!');
                                    }
                                }

                                return $sRoute;
                            }
                        }
                    }
                }
            }
        }
    }
public function getUrl(string $sCode, array $aParams = array()) : string
    {
        if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) {

            foreach (Config::get('route') as $sHost => $oHost) {

                if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST'])
                    || (strstr($sHost, '/')
                    && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) {

                    if (strstr($sHost, '/')
                        && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) {

                        $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost);
                    }

                    if (isset($oHost->routes)) {

                        foreach($oHost->routes as $sKey => $oRoute) {

                            if ($sKey === $sCode) {

                                $sRoute = $this->_sBaseUri.$oRoute->route;

                                if (isset($oRoute->constraints)) {

                                    foreach ($oRoute->constraints as $sName => $sType) {

                                        if (!isset($aParams[$sName])) { $aParams[$sName] = ''; }

                                        if (preg_match('#'.$sType.'#', $aParams[$sName])) {

                                            if ($aParams[$sName]) { $sRoute = str_replace('[/:'.$sName.']', '/'.$aParams[$sName], $sRoute); } else { $sRoute = str_replace('[/:'.$sName.']', '', $sRoute); }
                                            $sRoute = str_replace('[:'.$sName.']', $aParams[$sName], $sRoute);
                                            continue;
                                        } else if (isset($oRoute->defaults_constraints)
                                            && isset($oRoute->defaults_constraints->{$sName})
                                            && preg_match('#'.$sType.'#', $oRoute->defaults_constraints->{$sName})) {

                                            continue;
                                        }

                                        throw new \Exception('For the route '.$sCode.' the parameter '.$sName.' is not good!');
                                    }
                                }

                                return $sRoute;
                            }
                        }
                    }
                }
            }
        }
    }
public function getUrl ( string $ sCode , array $ aParams = array ( ) ) : string { if ( isset ( $ _SERVER ) && isset ( $ _SERVER [ 'HTTP_HOST' ] ) ) { foreach ( Config :: get ( 'route' ) as $ sHost => $ oHost ) { if ( ( ! strstr ( $ sHost , '/' ) && $ sHost == $ _SERVER [ 'HTTP_HOST' ] ) || ( strstr ( $ sHost , '/' ) && strstr ( $ _SERVER [ 'HTTP_HOST' ] . $ _SERVER [ 'REQUEST_URI' ] , $ sHost ) ) ) { if ( strstr ( $ sHost , '/' ) && strstr ( $ _SERVER [ 'HTTP_HOST' ] . $ _SERVER [ 'REQUEST_URI' ] , $ sHost ) ) { $ this -> _sBaseUri = preg_replace ( '#^[^/]+#' , '' , $ sHost ) ; } if ( isset ( $ oHost -> routes ) ) { foreach ( $ oHost -> routes as $ sKey => $ oRoute ) { if ( $ sKey === $ sCode ) { $ sRoute = $ this -> _sBaseUri . $ oRoute -> route ; if ( isset ( $ oRoute -> constraints ) ) { foreach ( $ oRoute -> constraints as $ sName => $ sType ) { if ( ! isset ( $ aParams [ $ sName ] ) ) { $ aParams [ $ sName ] = '' ; } if ( preg_match ( '#' . $ sType . '#' , $ aParams [ $ sName ] ) ) { if ( $ aParams [ $ sName ] ) { $ sRoute = str_replace ( '[/:' . $ sName . ']' , '/' . $ aParams [ $ sName ] , $ sRoute ) ; } else { $ sRoute = str_replace ( '[/:' . $ sName . ']' , '' , $ sRoute ) ; } $ sRoute = str_replace ( '[:' . $ sName . ']' , $ aParams [ $ sName ] , $ sRoute ) ; continue ; } else if ( isset ( $ oRoute -> defaults_constraints ) && isset ( $ oRoute -> defaults_constraints -> { $ sName } ) && preg_match ( '#' . $ sType . '#' , $ oRoute -> defaults_constraints -> { $ sName } ) ) { continue ; } throw new \ Exception ( 'For the route ' . $ sCode . ' the parameter ' . $ sName . ' is not good!' ) ; } } return $ sRoute ; } } } } } } }
create an URL

@access public
@param  string $sCode code of the url between "routes" and "route" in Route.conf
@param  array $aParams parameters to create the url
@return string

@tutorial	If I have this route I could make my URL:

"menu_edit": {
"route": "[/:language]/menu[/:id]/edit/",
"controller": "\\src\\BackOffice\\Controller\\MenuManager",
"action": "edit",
"constraints": {
"language": "[a-z]{0,2}",
"id": "[0-9]+"
},
"content_type": "html"
},

I must write this:

$oUrlManager = new \Venus\core\UrlManager;
$sUrl = $oUrlManager->getUrl('menu_edit', array('language' => 'vn', 'id' => 125));
create an URL