/** * Get the URL to a named route. * * @param string $name * @param array $params * @param bool $relative * * @return string */ public function getRouteUrl($name, array $params = array(), $relative = false) { $route = $this->router->getRoute($name); $routeParams = []; $query = []; foreach ($params as $key => $value) { if (is_int($key)) { $routeParams[] = $value; } else { $query[$key] = $value; } } $path = $this->routePathGenerator->getRoutePath($route, $routeParams); if ($query) { $path .= '?' . http_build_query($query); } if ($relative) { $root = $this->requests->getCurrentRequest()->getBaseUrl(); } else { $root = $this->getRootUrl(); } return $root . $path; }