public function Router::getGenerator

Gets the UrlGenerator instance associated with this Router.

Return value

UrlGeneratorInterface A UrlGeneratorInterface instance

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php, line 256

Class

Router
The Router class is an example of the integration of all pieces of the routing system for easier use.

Namespace

Symfony\Component\Routing

Code

public function getGenerator() {
  if (null !== $this->generator) {
    return $this->generator;
  }
  if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) {
    $this->generator = new $this->options['generator_class']($this
      ->getRouteCollection(), $this->context, $this->logger);
  }
  else {
    $class = $this->options['generator_cache_class'];
    $cache = new ConfigCache($this->options['cache_dir'] . '/' . $class . '.php', $this->options['debug']);
    if (!$cache
      ->isFresh($class)) {
      $dumper = new $this->options['generator_dumper_class']($this
        ->getRouteCollection());
      $options = array(
        'class' => $class,
        'base_class' => $this->options['generator_base_class'],
      );
      $cache
        ->write($dumper
        ->dump($options), $this
        ->getRouteCollection()
        ->getResources());
    }
    require_once $cache;
    $this->generator = new $class($this->context, $this->logger);
  }
  if ($this->generator instanceof ConfigurableRequirementsInterface) {
    $this->generator
      ->setStrictRequirements($this->options['strict_requirements']);
  }
  return $this->generator;
}