From c67dd4009fea4398c8882723030af80bb8daf4b5 Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 24 May 2019 13:53:43 +0300 Subject: [PATCH] Slim Framework integration #118 #117 - CsrfTwigExtension updates --- flextype/twig/CsrfTwigExtension.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/flextype/twig/CsrfTwigExtension.php b/flextype/twig/CsrfTwigExtension.php index 3c900569..62367b6b 100644 --- a/flextype/twig/CsrfTwigExtension.php +++ b/flextype/twig/CsrfTwigExtension.php @@ -49,4 +49,27 @@ class CsrfTwigExtension extends \Twig_Extension implements \Twig_Extension_Globa { return 'slim/csrf'; } + + /** + * Callback for twig. + * + * @return array + */ + public function getFunctions() + { + return [ + new \Twig_SimpleFunction('csrf', [$this, 'csrf'], ['is_safe' => ['html']]), + ]; + } + + /** + * CSRF + * + * @return string + */ + public function csrf() + { + return ''. + ''; + } }