Commit ab54a1bd authored by Bilal Amarni's avatar Bilal Amarni

simplified form factory creation

parent ad563dde
......@@ -13,15 +13,13 @@ namespace Silex\Provider;
use Silex\Application;
use Silex\ServiceProviderInterface;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension as FormValidatorExtension;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Symfony\Component\Form\Forms;
/**
* Symfony Form component Provider.
......@@ -51,7 +49,6 @@ class FormServiceProvider implements ServiceProviderInterface
$app['form.extensions'] = $app->share(function ($app) {
$extensions = array(
new CoreExtension(),
new CsrfExtension($app['form.csrf_provider']),
new HttpFoundationExtension(),
);
......@@ -68,16 +65,11 @@ class FormServiceProvider implements ServiceProviderInterface
return $extensions;
});
$app['form.resolved_type_factory'] = $app->share(function ($app) {
return new ResolvedFormTypeFactory();
});
$app['form.registry'] = $app->share(function ($app) {
return new FormRegistry($app['form.extensions'], $app['form.resolved_type_factory']);
});
$app['form.factory'] = $app->share(function ($app) {
return new FormFactory($app['form.registry'], $app['form.resolved_type_factory']);
return Forms::createFormFactoryBuilder()
->addExtensions($app['form.extensions'])
->getFormFactory()
;
});
$app['form.csrf_provider'] = $app->share(function ($app) {
......
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