/** * @param View $view */ protected function registerTwigFunctions_urlGenerator(View $view) { $urlGenerator = $this->urlGenerator; $view->addFunction('path', function ($routeName, $arguments = []) use($urlGenerator) { return $urlGenerator->generate($routeName, $arguments); }); }
/** * @param View $view */ protected function registerTwigFunctions_csrf(View $view) { if (isset($this->csrfTokenManager)) { /** @var CsrfTokenManager $csrfTokenManager */ $csrfTokenManager = $this->csrfTokenManager; $view->addFunction('csrfToken', function ($tokenId) use($csrfTokenManager) { return $csrfTokenManager->getToken($tokenId); }); } }
/** * @return string */ public function render() { return $this->view->render(); }