/** * @param string $name : the name of the route to link * @param array $namedParams : a map of parameter names => values * @return null|Uri the link to the named route with the parameters replaced, or null if no route was found */ public static function link(string $name, array $namedParams = []) { if (isset(self::$routes[$name])) { $route = self::$routes[$name]->generateLink($namedParams); $uri = App::getRequest()->getUri()->copy()->setPath($route)->setQuery(''); if (self::$routes[$name]->getRequireHttps()) { $uri->setScheme('https'); } return $uri; } return null; }