Commit 22cc6fd
committed
bug #6881 Error in CSRF example code snippet (makoru-hikage)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #6881).
Discussion
----------
Error in CSRF example code snippet
Something's wrong when I tried this code:
```
$session = new Session();
$csrfGenerator = new UriSafeTokenGenerator();
$csrfStorage = new SessionTokenStorage($session);
$csrfManager = new CsrfTokenManager($csrfGenerator, $csrfStorage);
$formFactory = Forms::createFormFactoryBuilder()
// ...
->addExtension(new CsrfExtension($csrfStorage))
->getFormFactory();
```
Constructing a `CsrfExtension` requires a `CsrfTokenManagerInterface` as an argument (see symfony/form/Extension/Csrf/CsrfExtension.php, line 47).
The `$csrfStorage` in `addExtension(new CsrfExtension($csrfStorage)`, has a class that implements `TokenStorageInterface` (see symfony/security-csrf/TokenStorage/SessionStorageToken.php, line 22).
So I replaced it with `$csrfManager` that has class that implements `CsrfTokenManagerInterface`. (see symfony/security-csrf/CsrfTokenManager.php, line 24)
Commits
-------
80c09dd Error in CSRF example code snippet1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
0 commit comments