Skip to content

Commit c909000

Browse files
committed
feature #20135 document the requests constructor argument of the RequestStack class (xabbuh)
This PR was merged into the 7.2 branch. Discussion ---------- document the requests constructor argument of the RequestStack class fixes #20092 Commits ------- 51fdaa8 document the requests constructor argument of the RequestStack class
2 parents f1c7127 + 51fdaa8 commit c909000

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

components/form.rst

+6-2
Original file line numberDiff line numberDiff 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+
138142
Internally, this extension will automatically add a hidden field to every
139143
form (called ``_token`` by default) whose value is automatically generated by
140144
the CSRF generator and validated when binding the form.

0 commit comments

Comments
 (0)