Commit adace223 authored by Fabien Potencier's avatar Fabien Potencier

added SessionCsrfProvider support in FormExtension when SessionExtension is registered

parent 73bb2b07
......@@ -14,6 +14,7 @@ namespace Silex\Extension;
use Silex\Application;
use Silex\ExtensionInterface;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension as FormValidatorExtension;
......@@ -44,6 +45,10 @@ class FormExtension implements ExtensionInterface
});
$app['form.csrf_provider'] = $app->share(function () use ($app) {
if (isset($app['session'])) {
return new SessionCsrfProvider($app['session'], $app['form.secret']);
}
return new DefaultCsrfProvider($app['form.secret']);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment