-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSuperStaticCacheTags.php
36 lines (29 loc) · 1011 Bytes
/
SuperStaticCacheTags.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace Statamic\Addons\SuperStaticCache;
use Statamic\Extend\Extensible;
use Statamic\Extend\Tags;
use Statamic\View\Antlers\Template;
class SuperStaticCacheTags extends Tags
{
use Extensible;
/**
* The {{ super_static_cache:pouplate_csrf_tokens }} tag.
*
* Calls the token API and injects the CSRF tokens in each _token form input field.
* You may optionally pass a "form_selector" parameter which is used to find the
* Statamic forms in the DOM, e.g. form_selector="[data-statamic-form]".
*
* @return string|null
*/
public function populateCsrfTokens()
{
if (!$this->getConfigBool('dynamic_csrf_enabled')) {
return null;
}
$formSelector = $this->getParam('form_selector', 'form');
$template = $this->getDirectory() . '/templates/dynamic_csrf_tokens.antlers.html';
return Template::parse(file_get_contents($template), [
'form_selector' => $formSelector,
]);
}
}