Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit934118b

Browse files
stofnicolas-grekas
authored andcommitted
Fix the configurability of CoreExtension deps in standalone usage
1 parentc82e2df commit934118b

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected function loadTypes()
6969
newType\TimeType(),
7070
newType\TimezoneType(),
7171
newType\UrlType(),
72-
newType\FileType(),
72+
newType\FileType($this->translator),
7373
newType\ButtonType(),
7474
newType\SubmitType(),
7575
newType\ResetType(),

‎src/Symfony/Component/Form/FormFactoryBuilder.php‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111

1212
namespaceSymfony\Component\Form;
1313

14+
useSymfony\Component\Form\Extension\Core\CoreExtension;
15+
1416
/**
1517
* The default implementation of FormFactoryBuilderInterface.
1618
*
1719
* @author Bernhard Schussek <bschussek@gmail.com>
1820
*/
1921
class FormFactoryBuilderimplements FormFactoryBuilderInterface
2022
{
23+
private$forceCoreExtension;
24+
2125
/**
2226
* @var ResolvedFormTypeFactoryInterface
2327
*/
@@ -43,6 +47,14 @@ class FormFactoryBuilder implements FormFactoryBuilderInterface
4347
*/
4448
private$typeGuessers = [];
4549

50+
/**
51+
* @param bool $forceCoreExtension
52+
*/
53+
publicfunction__construct($forceCoreExtension =false)
54+
{
55+
$this->forceCoreExtension =$forceCoreExtension;
56+
}
57+
4658
/**
4759
* {@inheritdoc}
4860
*/
@@ -144,6 +156,21 @@ public function getFormFactory()
144156
{
145157
$extensions =$this->extensions;
146158

159+
if ($this->forceCoreExtension) {
160+
$hasCoreExtension =false;
161+
162+
foreach ($extensionsas$extension) {
163+
if ($extensioninstanceof CoreExtension) {
164+
$hasCoreExtension =true;
165+
break;
166+
}
167+
}
168+
169+
if (!$hasCoreExtension) {
170+
array_unshift($extensions,newCoreExtension());
171+
}
172+
}
173+
147174
if (\count($this->types) >0 ||\count($this->typeExtensions) >0 ||\count($this->typeGuessers) >0) {
148175
if (\count($this->typeGuessers) >1) {
149176
$typeGuesser =newFormTypeGuesserChain($this->typeGuessers);

‎src/Symfony/Component/Form/Forms.php‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespaceSymfony\Component\Form;
1313

14-
useSymfony\Component\Form\Extension\Core\CoreExtension;
15-
1614
/**
1715
* Entry point of the Form component.
1816
*
@@ -105,10 +103,7 @@ public static function createFormFactory()
105103
*/
106104
publicstaticfunctioncreateFormFactoryBuilder()
107105
{
108-
$builder =newFormFactoryBuilder();
109-
$builder->addExtension(newCoreExtension());
110-
111-
return$builder;
106+
returnnewFormFactoryBuilder(true);
112107
}
113108

114109
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp