Skip to content

Commit 244c8d5

Browse files
committed
make csrf_token() usable without forms
The Twig function `csrf_token()` is currently only registered when the Form component is installed. However, this function is also useful, for example, when creating simple login forms for which you do not need the full Form component.
1 parent 0ca32aa commit 244c8d5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Resources/config/security_csrf.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,10 @@
2121
<argument type="service" id="request_stack" on-invalid="ignore" />
2222
</service>
2323
<service id="Symfony\Component\Security\Csrf\CsrfTokenManagerInterface" alias="security.csrf.token_manager" />
24+
25+
<service id="twig.extension.security_csrf" class="Symfony\Bridge\Twig\Extension\CsrfExtension">
26+
<tag name="twig.extension" />
27+
<argument type="service" id="security.csrf.token_manager" />
28+
</service>
2429
</services>
2530
</container>

0 commit comments

Comments
 (0)