From 9e217d87c095170460a8580d5215ddf7cbe639f4 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 2 Sep 2018 02:09:56 +0200 Subject: Template refactoring to use twig --- src/Renderer/Twig/Extensions/Legacy.php | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/Renderer/Twig/Extensions/Legacy.php (limited to 'src/Renderer/Twig/Extensions/Legacy.php') diff --git a/src/Renderer/Twig/Extensions/Legacy.php b/src/Renderer/Twig/Extensions/Legacy.php new file mode 100644 index 00000000..79de32cb --- /dev/null +++ b/src/Renderer/Twig/Extensions/Legacy.php @@ -0,0 +1,49 @@ +request = $request; + } + + /** + * @return TwigFunction[] + */ + public function getFunctions() + { + $isSafeHtml = ['is_safe' => ['html']]; + return [ + new TwigFunction('menu', 'make_navigation', $isSafeHtml), + new TwigFunction('menuUserShiftState', 'User_shift_state_render', $isSafeHtml), + new TwigFunction('menuUserMessages', 'user_unread_messages', $isSafeHtml), + new TwigFunction('menuUserHints', 'header_render_hints', $isSafeHtml), + new TwigFunction('menuUserSubmenu', 'make_user_submenu', $isSafeHtml), + new TwigFunction('page', [$this, 'getPage']), + ]; + } + + /** + * @return string + */ + public function getPage() + { + if ($this->request->has('p')) { + return $this->request->get('p'); + } + + return $this->request->path(); + } +} -- cgit v1.2.3-54-g00ecf