1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-28 23:40:41 +02:00

Slim Framework integration #118 #117

- CsrfTwigExtension updates
This commit is contained in:
Awilum
2019-05-24 13:53:43 +03:00
parent b29a051f73
commit c67dd4009f

View File

@@ -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 '<input type="hidden" name="'.$this->csrf->getTokenNameKey().'" value="'.$this->csrf->getTokenName().'">'.
'<input type="hidden" name="'.$this->csrf->getTokenValueKey().'" value="'.$this->csrf->getTokenValue().'">';
}
}