diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml index 9cc86bded2..3d13360346 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml @@ -97,7 +97,7 @@ - + %templating.helper.form.resources% diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php index 084381aa1e..e0f06f12b2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php @@ -47,7 +47,7 @@ class FormHelper extends Helper * @param CsrfProviderInterface $csrfProvider The CSRF provider * @param array $resources An array of theme names */ - public function __construct(EngineInterface $engine, CsrfProviderInterface $csrfProvider, array $resources) + public function __construct(EngineInterface $engine, CsrfProviderInterface $csrfProvider = null, array $resources = array()) { $this->engine = $engine; $this->csrfProvider = $csrfProvider; @@ -202,6 +202,10 @@ class FormHelper extends Helper */ public function csrfToken($intention) { + if (! $this->csrfProvider instanceof CsrfProviderInterface) { + throw new \BadMethodCallException('CSRF token can only be generated if the "form.csrf_provider" service is available'); + } + return $this->csrfProvider->generateCsrfToken($intention); }