Commit 02ba1df9 authored by Fabien Potencier's avatar Fabien Potencier

feature #1473 Added the FormRegistry as a service to enable the extension point (HeahDude)

This PR was merged into the 2.1.x-dev branch.

Discussion
----------

Added the FormRegistry as a service to enable the extension point

Closes https://github.com/symfony/symfony/issues/21199.

This PR makes the form configuration aligned with the symfony full stack, see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml#L11-L29.

Commits
-------

01f90256 Added the FormRegistry as a service to enable the extension point
parents 8ac290c5 01f90256
...@@ -16,7 +16,8 @@ use Pimple\ServiceProviderInterface; ...@@ -16,7 +16,8 @@ use Pimple\ServiceProviderInterface;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension; use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension; use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension as FormValidatorExtension; use Symfony\Component\Form\Extension\Validator\ValidatorExtension as FormValidatorExtension;
use Symfony\Component\Form\Forms; use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\ResolvedFormTypeFactory; use Symfony\Component\Form\ResolvedFormTypeFactory;
/** /**
...@@ -74,11 +75,11 @@ class FormServiceProvider implements ServiceProviderInterface ...@@ -74,11 +75,11 @@ class FormServiceProvider implements ServiceProviderInterface
}; };
$app['form.factory'] = function ($app) { $app['form.factory'] = function ($app) {
return Forms::createFormFactoryBuilder() return new FormFactory($app['form.registry'], $app['form.resolved_type_factory']);
->addExtensions($app['form.extensions']) };
->setResolvedTypeFactory($app['form.resolved_type_factory'])
->getFormFactory() $app['form.registry'] = function ($app) {
; return new FormRegistry($app['form.extensions'], $app['form.resolved_type_factory']);
}; };
$app['form.resolved_type_factory'] = function ($app) { $app['form.resolved_type_factory'] = function ($app) {
......
...@@ -34,6 +34,13 @@ class FormServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -34,6 +34,13 @@ class FormServiceProviderTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('Symfony\Component\Form\FormFactory', $app['form.factory']); $this->assertInstanceOf('Symfony\Component\Form\FormFactory', $app['form.factory']);
} }
public function testFormRegistryServiceIsFormRegistry()
{
$app = new Application();
$app->register(new FormServiceProvider());
$this->assertInstanceOf('Symfony\Component\Form\FormRegistry', $app['form.registry']);
}
public function testFormServiceProviderWillLoadTypes() public function testFormServiceProviderWillLoadTypes()
{ {
$app = new Application(); $app = new Application();
......
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