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 ''. + ''; + } }