Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b39ebc

Browse files
committed
merged branch bschussek/httpfoundationextension (PR #5103)
Commits ------- 173b929 [Form] Completely decoupled CoreExtension from HttpFoundation Discussion ---------- [Form] Completely decoupled CoreExtension from HttpFoundation Bug fix: no Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: - Todo: -
2 parents 83c41ff + 173b929 commit 6b39ebc

File tree

8 files changed

+92
-19
lines changed

8 files changed

+92
-19
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<!--
1919
We don't need to be able to add more extensions.
2020
* more types can be registered with the form.type tag
21+
* more type extensions can be registered with the form.type_extension tag
2122
* more type_guessers can be registered with the form.type.type_guesser tag
2223
-->
2324
<argument type="service" id="form.extension" />
@@ -32,20 +33,11 @@
3233
<!-- DependencyInjectionExtension -->
3334
<service id="form.extension" class="%form.extension.class%" public="false">
3435
<argument type="service" id="service_container" />
35-
<!--
36-
All services with tag "form.type" are inserted here by
37-
InitFormsPass
38-
-->
36+
<!-- All services with tag "form.type" are inserted here by FormPass -->
3937
<argument type="collection" />
40-
<!--
41-
All services with tag "form.type_extension" are inserted here by
42-
InitFormsPass
43-
-->
38+
<!-- All services with tag "form.type_extension" are inserted here by FormPass -->
4439
<argument type="collection" />
45-
<!--
46-
All services with tag "form.type_guesser" are inserted here by
47-
InitFormsPass
48-
-->
40+
<!-- All services with tag "form.type_guesser" are inserted here by FormPass -->
4941
<argument type="collection" />
5042
</service>
5143

@@ -138,6 +130,11 @@
138130
<tag name="form.type" alias="url" />
139131
</service>
140132

133+
<!-- FormTypeHttpFoundationExtension -->
134+
<service id="form.type_extension.form.http_foundation" class="Symfony\Component\Form\Extension\HttpFoundation\Type\FormTypeHttpFoundationExtension">
135+
<tag name="form.type_extension" alias="form" />
136+
</service>
137+
141138
<!-- FormTypeValidatorExtension -->
142139
<service id="form.type_extension.form.validator" class="Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension">
143140
<tag name="form.type_extension" alias="form" />

src/Symfony/Component/Form/Extension/Core/CoreExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Form\Extension\Core;
1313

14-
use Symfony\Component\Form\Extension\Core\Type;
1514
use Symfony\Component\Form\AbstractExtension;
1615

1716
/**

src/Symfony/Component/Form/Extension/Core/Type/FormType.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\Form\FormInterface;
1818
use Symfony\Component\Form\FormFactoryInterface;
1919
use Symfony\Component\Form\FormView;
20-
use Symfony\Component\Form\Extension\Core\EventListener\BindRequestListener;
2120
use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
2221
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
2322
use Symfony\Component\Form\Exception\FormException;
@@ -45,7 +44,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
4544
->setData(isset($options['data']) ? $options['data'] : null)
4645
->setDataLocked(isset($options['data']))
4746
->setDataMapper($options['compound'] ? new PropertyPathMapper() : null)
48-
->addEventSubscriber(new BindRequestListener())
4947
;
5048

5149
if ($options['trim']) {

src/Symfony/Component/Form/Extension/Core/EventListener/BindRequestListener.php renamed to src/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Form\Extension\Core\EventListener;
12+
namespace Symfony\Component\Form\Extension\HttpFoundation\EventListener;
1313

1414
use Symfony\Component\Form\FormEvents;
1515
use Symfony\Component\Form\FormEvent;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Extension\HttpFoundation;
13+
14+
use Symfony\Component\Form\AbstractExtension;
15+
16+
/**
17+
* Integrates the HttpFoundation component with the Form library.
18+
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*/
21+
class HttpFoundationExtension extends AbstractExtension
22+
{
23+
protected function loadTypes()
24+
{
25+
return array(
26+
new Type\FormTypeHttpFoundationExtension(),
27+
);
28+
}
29+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Extension\HttpFoundation\Type;
13+
14+
use Symfony\Component\Form\AbstractTypeExtension;
15+
use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
16+
use Symfony\Component\Form\FormBuilderInterface;
17+
use Symfony\Component\OptionsResolver\Options;
18+
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
19+
20+
/**
21+
* @author Bernhard Schussek <[email protected]>
22+
*/
23+
class FormTypeHttpFoundationExtension extends AbstractTypeExtension
24+
{
25+
/**
26+
* @var BindRequestListener
27+
*/
28+
private $listener;
29+
30+
public function __construct()
31+
{
32+
$this->listener = new BindRequestListener();
33+
}
34+
35+
/**
36+
* {@inheritdoc}
37+
*/
38+
public function buildForm(FormBuilderInterface $builder, array $options)
39+
{
40+
$builder->addEventSubscriber($this->listener);
41+
}
42+
43+
/**
44+
* {@inheritdoc}
45+
*/
46+
public function getExtendedType()
47+
{
48+
return 'form';
49+
}
50+
}

src/Symfony/Component/Form/Tests/CompoundFormTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Form\Form;
1515
use Symfony\Component\Form\FormView;
1616
use Symfony\Component\Form\FormError;
17-
use Symfony\Component\Form\Extension\Core\EventListener\BindRequestListener;
17+
use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
1818
use Symfony\Component\HttpFoundation\Request;
1919
use Symfony\Component\HttpFoundation\File\UploadedFile;
2020
use Symfony\Component\EventDispatcher\EventDispatcher;

src/Symfony/Component/Form/Tests/Extension/Core/EventListener/BindRequestListenerTest.php renamed to src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
12+
namespace Symfony\Component\Form\Tests\Extension\HttpFoundation\EventListener;
1313

14-
use Symfony\Component\Form\Extension\Core\EventListener\BindRequestListener;
14+
use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
1515
use Symfony\Component\Form\Form;
1616
use Symfony\Component\Form\FormConfigBuilder;
1717
use Symfony\Component\Form\FormEvent;

0 commit comments

Comments
 (0)