urlGenerator = $urlGenerator; } /** * @return TwigFunction[] */ public function getFunctions() { return [ new TwigFunction('asset', [$this, 'getAsset']), ]; } /** * @param string $path * @return UrlGenerator|string */ public function getAsset($path) { $path = ltrim($path, '/'); return $this->urlGenerator->to('/' . $path); } }