public function Router::getGenerator in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/routing/Router.php \Symfony\Component\Routing\Router::getGenerator()
Gets the UrlGenerator instance associated with this Router.
Return value
UrlGeneratorInterface A UrlGeneratorInterface instance
File
- vendor/
symfony/ routing/ Router.php, line 314
Class
- Router
- The Router class is an example of the integration of all pieces of the routing system for easier use.
Namespace
Symfony\Component\RoutingCode
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'];
$baseClass = $this->options['generator_base_class'];
$that = $this;
// required for PHP 5.3 where "$this" cannot be use()d in anonymous functions. Change in Symfony 3.0.
$cache = $this
->getConfigCacheFactory()
->cache($this->options['cache_dir'] . '/' . $class . '.php', function (ConfigCacheInterface $cache) use ($that, $class, $baseClass) {
$dumper = $that
->getGeneratorDumperInstance();
$options = array(
'class' => $class,
'base_class' => $baseClass,
);
$cache
->write($dumper
->dump($options), $that
->getRouteCollection()
->getResources());
});
require_once $cache
->getPath();
$this->generator = new $class($this->context, $this->logger);
}
if ($this->generator instanceof ConfigurableRequirementsInterface) {
$this->generator
->setStrictRequirements($this->options['strict_requirements']);
}
return $this->generator;
}