<?php
namespace Nellapp\Bundle\SDKBundle\Routing;
use Nellapp\Bundle\SDKBundle\Routing\ChannelMainDomain\ChannelMainDomainInterface;
use Nellapp\Bundle\SDKBundle\Routing\ChannelMainDomain\ChannelMainDomainTrait;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
class SymfonyUrlGenerator implements RouterInterface, WarmableInterface, ChannelMainDomainInterface
{
use ChannelMainDomainTrait;
public function __construct(
private RouterInterface $inner,
private RequestContext $context,
)
{
}
public function generate($name, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
$route = $this->inner->getRouteCollection()->get($name);
$this->applyChannelDomain($route, $this->context, $parameters);
return $this->inner->generate($name, $parameters, $referenceType);
}
public function setContext(RequestContext $context)
{
$this->inner->setContext($context);
$this->context = $context;
}
public function getContext()
{
return $this->context;
}
public function getRouteCollection(): RouteCollection
{
return $this->inner->getRouteCollection();
}
public function match($pathinfo): array
{
return $this->inner->match($pathinfo);
}
public function warmUp(string $cacheDir): array
{
return $this->inner->warmUp($cacheDir);
}
}