Skip to content

Commit 3d4ef71

Browse files
committed
feature #25197 [FrameworkBundle][TwigBridge] make csrf_token() usable without forms (xabbuh)
This PR was merged into the 4.1-dev branch. Discussion ---------- [FrameworkBundle][TwigBridge] make csrf_token() usable without forms | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | 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. Commits ------- 709efa30fc make csrf_token() usable without forms
2 parents 650850a + 244c8d5 commit 3d4ef71

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)