Browse files

simplified form factory creation

  • Loading branch information...
1 parent ad563dd commit ab54a1bdd2b3d0a1d3b73525fc862575471baa5c @bamarni bamarni committed Sep 9, 2012
Showing with 5 additions and 13 deletions.
  1. +5 −13 src/Silex/Provider/FormServiceProvider.php
View
18 src/Silex/Provider/FormServiceProvider.php
@@ -13,15 +13,13 @@
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 @@ public function register(Application $app)
$app['form.extensions'] = $app->share(function ($app) {
$extensions = array(
- new CoreExtension(),
new CsrfExtension($app['form.csrf_provider']),
new HttpFoundationExtension(),
);
@@ -68,16 +65,11 @@ public function register(Application $app)
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) {

0 comments on commit ab54a1b

Please sign in to comment.