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::
123123 use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
124124
125125 // creates a RequestStack object using the current request
126- $requestStack = new RequestStack();
127- $requestStack->push($request);
126+ $requestStack = new RequestStack([$request]);
128127
129128 $csrfGenerator = new UriSafeTokenGenerator();
130129 $csrfStorage = new SessionTokenStorage($requestStack);
@@ -135,6 +134,11 @@ The following snippet adds CSRF protection to the form factory::
135134 ->addExtension(new CsrfExtension($csrfManager))
136135 ->getFormFactory();
137136
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+
138142Internally, this extension will automatically add a hidden field to every
139143form (called ``_token `` by default) whose value is automatically generated by
140144the CSRF generator and validated when binding the form.
You can’t perform that action at this time.
0 commit comments