public function getGenerator(): UrlGeneratorInterface
{ if (null !==
$this->generator
) { return $this->generator;
} if (null ===
$this->options
['cache_dir'
]) { $routes =
$this->
getRouteCollection();
$compiled =
is_a($this->options
['generator_class'
], CompiledUrlGenerator::
class, true
);
if ($compiled) { $generatorDumper =
new CompiledUrlGeneratorDumper($routes);
$routes =
array_merge($generatorDumper->
getCompiledRoutes(),
$generatorDumper->
getCompiledAliases());
} $this->generator =
new $this->options
['generator_class'
]($routes,
$this->context,
$this->logger,
$this->defaultLocale
);
} else { $cache =
$this->
getConfigCacheFactory()->
cache($this->options
['cache_dir'
].'/url_generating_routes.php',
function DConfigCacheInterface
$cache) { $dumper =
$this->
getGeneratorDumperInstance();
$cache->
write($dumper->
dump(),
$this->
getRouteCollection()->
getResources());
} );