File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -123,8 +123,7 @@ The following snippet adds CSRF protection to the form factory::
123
123
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
124
124
125
125
// creates a RequestStack object using the current request
126
- $requestStack = new RequestStack();
127
- $requestStack->push($request);
126
+ $requestStack = new RequestStack([$request]);
128
127
129
128
$csrfGenerator = new UriSafeTokenGenerator();
130
129
$csrfStorage = new SessionTokenStorage($requestStack);
@@ -135,6 +134,11 @@ The following snippet adds CSRF protection to the form factory::
135
134
->addExtension(new CsrfExtension($csrfManager))
136
135
->getFormFactory();
137
136
137
+ .. versionadded :: 7.2
138
+
139
+ Support for passing requests to the constructor of the ``RequestStack ``
140
+ class was introduced in Symfony 7.2.
141
+
138
142
Internally, this extension will automatically add a hidden field to every
139
143
form (called ``_token `` by default) whose value is automatically generated by
140
144
the CSRF generator and validated when binding the form.
You can’t perform that action at this time.
0 commit comments