From 1c806c720e7b1558ba84b6d4353a3ea6554b72a0 Mon Sep 17 00:00:00 2001 From: m_hikage Date: Wed, 17 Aug 2016 12:48:39 +0800 Subject: [PATCH] Error in CSRF example code snippet Something's wrong when I tried this code: `$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 24). 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 implement `CsrfTokenManagerInterface`. (see symfony/security-csrf/CsrfTokenManager.php, line 24) --- components/form.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/form.rst b/components/form.rst index 9590929848b..4b8a2500fc6 100644 --- a/components/form.rst +++ b/components/form.rst @@ -134,7 +134,7 @@ The following snippet adds CSRF protection to the form factory:: $formFactory = Forms::createFormFactoryBuilder() // ... - ->addExtension(new CsrfExtension($csrfStorage)) + ->addExtension(new CsrfExtension($csrfManager)) ->getFormFactory(); Internally, this extension will automatically add a hidden field to every