<?php
namespace Symfony\Component\Routing\Generator;
use Psr\Log\LoggerInterface;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\RequestContext;
class CompiledUrlGenerator extends UrlGenerator
{
private array $compiledRoutes = [];
private ?string $defaultLocale;
public function __construct(array $compiledRoutes, RequestContext $context, ?LoggerInterface $logger = null, ?string $defaultLocale = null)
{
$this->compiledRoutes = $compiledRoutes;
$this->context = $context;
$this->logger = $logger;
$this->defaultLocale = $defaultLocale;
}
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string
{
$locale = $parameters['_locale']
?? $this->context->getParameter('_locale')
?: $this->defaultLocale;
if (null !== $locale) {
do {
if (($this->compiledRoutes[$name.'.'.$locale][1]['_canonical_route'] ?? null) === $name) {
$name .= '.'.$locale;
break;
}