[Form] Completely decoupled CoreExtension from HttpFoundation
This commit is contained in:
parent
50652a9717
commit
173b929219
@ -18,6 +18,7 @@
|
|||||||
<!--
|
<!--
|
||||||
We don't need to be able to add more extensions.
|
We don't need to be able to add more extensions.
|
||||||
* more types can be registered with the form.type tag
|
* more types can be registered with the form.type tag
|
||||||
|
* more type extensions can be registered with the form.type_extension tag
|
||||||
* more type_guessers can be registered with the form.type.type_guesser tag
|
* more type_guessers can be registered with the form.type.type_guesser tag
|
||||||
-->
|
-->
|
||||||
<argument type="service" id="form.extension" />
|
<argument type="service" id="form.extension" />
|
||||||
@ -32,20 +33,11 @@
|
|||||||
<!-- DependencyInjectionExtension -->
|
<!-- DependencyInjectionExtension -->
|
||||||
<service id="form.extension" class="%form.extension.class%" public="false">
|
<service id="form.extension" class="%form.extension.class%" public="false">
|
||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
<!--
|
<!-- All services with tag "form.type" are inserted here by FormPass -->
|
||||||
All services with tag "form.type" are inserted here by
|
|
||||||
InitFormsPass
|
|
||||||
-->
|
|
||||||
<argument type="collection" />
|
<argument type="collection" />
|
||||||
<!--
|
<!-- All services with tag "form.type_extension" are inserted here by FormPass -->
|
||||||
All services with tag "form.type_extension" are inserted here by
|
|
||||||
InitFormsPass
|
|
||||||
-->
|
|
||||||
<argument type="collection" />
|
<argument type="collection" />
|
||||||
<!--
|
<!-- All services with tag "form.type_guesser" are inserted here by FormPass -->
|
||||||
All services with tag "form.type_guesser" are inserted here by
|
|
||||||
InitFormsPass
|
|
||||||
-->
|
|
||||||
<argument type="collection" />
|
<argument type="collection" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
@ -138,6 +130,11 @@
|
|||||||
<tag name="form.type" alias="url" />
|
<tag name="form.type" alias="url" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<!-- FormTypeHttpFoundationExtension -->
|
||||||
|
<service id="form.type_extension.form.http_foundation" class="Symfony\Component\Form\Extension\HttpFoundation\Type\FormTypeHttpFoundationExtension">
|
||||||
|
<tag name="form.type_extension" alias="form" />
|
||||||
|
</service>
|
||||||
|
|
||||||
<!-- FormTypeValidatorExtension -->
|
<!-- FormTypeValidatorExtension -->
|
||||||
<service id="form.type_extension.form.validator" class="Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension">
|
<service id="form.type_extension.form.validator" class="Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension">
|
||||||
<tag name="form.type_extension" alias="form" />
|
<tag name="form.type_extension" alias="form" />
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Extension\Core;
|
namespace Symfony\Component\Form\Extension\Core;
|
||||||
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type;
|
|
||||||
use Symfony\Component\Form\AbstractExtension;
|
use Symfony\Component\Form\AbstractExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormFactoryInterface;
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\Form\Extension\Core\EventListener\BindRequestListener;
|
|
||||||
use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
|
use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
|
||||||
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
|
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
|
||||||
use Symfony\Component\Form\Exception\FormException;
|
use Symfony\Component\Form\Exception\FormException;
|
||||||
@ -45,7 +44,6 @@ class FormType extends AbstractType
|
|||||||
->setData(isset($options['data']) ? $options['data'] : null)
|
->setData(isset($options['data']) ? $options['data'] : null)
|
||||||
->setDataLocked(isset($options['data']))
|
->setDataLocked(isset($options['data']))
|
||||||
->setDataMapper($options['compound'] ? new PropertyPathMapper() : null)
|
->setDataMapper($options['compound'] ? new PropertyPathMapper() : null)
|
||||||
->addEventSubscriber(new BindRequestListener())
|
|
||||||
;
|
;
|
||||||
|
|
||||||
if ($options['trim']) {
|
if ($options['trim']) {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Symfony\Component\Form\Extension\Core\EventListener;
|
namespace Symfony\Component\Form\Extension\HttpFoundation\EventListener;
|
||||||
|
|
||||||
use Symfony\Component\Form\FormEvents;
|
use Symfony\Component\Form\FormEvents;
|
||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Form\Extension\HttpFoundation;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integrates the HttpFoundation component with the Form library.
|
||||||
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class HttpFoundationExtension extends AbstractExtension
|
||||||
|
{
|
||||||
|
protected function loadTypes()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
new Type\FormTypeHttpFoundationExtension(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Form\Extension\HttpFoundation\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
|
use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class FormTypeHttpFoundationExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var BindRequestListener
|
||||||
|
*/
|
||||||
|
private $listener;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->listener = new BindRequestListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder->addEventSubscriber($this->listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getExtendedType()
|
||||||
|
{
|
||||||
|
return 'form';
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Form\Tests;
|
|||||||
use Symfony\Component\Form\Form;
|
use Symfony\Component\Form\Form;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\Form\FormError;
|
use Symfony\Component\Form\FormError;
|
||||||
use Symfony\Component\Form\Extension\Core\EventListener\BindRequestListener;
|
use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
|
namespace Symfony\Component\Form\Tests\Extension\HttpFoundation\EventListener;
|
||||||
|
|
||||||
use Symfony\Component\Form\Extension\Core\EventListener\BindRequestListener;
|
use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
|
||||||
use Symfony\Component\Form\Form;
|
use Symfony\Component\Form\Form;
|
||||||
use Symfony\Component\Form\FormConfigBuilder;
|
use Symfony\Component\Form\FormConfigBuilder;
|
||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
Reference in New Issue
Block a user