urlGenerator = $urlGenerator; } /** * @return TwigFunction[] */ public function getFunctions() { return [ new TwigFunction('url', [$this, 'getUrl']), ]; } /** * @param string $path * @param array $parameters * @return UrlGenerator|string */ public function getUrl($path, $parameters = []) { $path = str_replace('_', '-', $path); return $this->urlGenerator->to($path, $parameters); } }