CodeExplorer rawUrl example
public function __construct( private readonly RouterInterface
$router,
private readonly RequestStack
$stack ) { } public function getFunctions(): array
{ return [ new TwigFunction('rawUrl',
$this->
rawUrl(...
)),
];
} public function rawUrl(string
$name, array
$parameters =
[], ?string
$domain = null
): string
{ $request =
$this->stack->
getMainRequest();
if (!
$request) { $url =
$this->router->
generate($name,
$parameters);
return $this->
addDomain($url,
$domain);
}