public function UrlGenerator::generate

Generates a URL from the given parameters.

If the generator is not able to generate the url, it must throw the RouteNotFoundException as documented below.

@api

Parameters

string $name The name of the route:

mixed $parameters An array of parameters:

Boolean $absolute Whether to generate an absolute URL:

Return value

string The generated URL

Throws

RouteNotFoundException if route doesn't exist

Overrides UrlGeneratorInterface::generate

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php, line 116

Class

UrlGenerator
UrlGenerator generates a URL based on a set of routes.

Namespace

Symfony\Component\Routing\Generator

Code

public function generate($name, $parameters = array(), $absolute = false) {
  if (null === ($route = $this->routes
    ->get($name))) {
    throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
  }

  // the Route has a cache of its own and is not recompiled as long as it does not get modified
  $compiledRoute = $route
    ->compile();
  return $this
    ->doGenerate($compiledRoute
    ->getVariables(), $route
    ->getDefaults(), $route
    ->getRequirements(), $compiledRoute
    ->getTokens(), $parameters, $name, $absolute);
}