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

Appearance settings

Commit 934118b

Browse filesBrowse files
stofnicolas-grekas
authored andcommitted
Fix the configurability of CoreExtension deps in standalone usage
1 parent c82e2df commit 934118b
Copy full SHA for 934118b

File tree

3 files changed

+29
-7
lines changed
Filter options

3 files changed

+29
-7
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/CoreExtension.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected function loadTypes()
6969
new Type\TimeType(),
7070
new Type\TimezoneType(),
7171
new Type\UrlType(),
72-
new Type\FileType(),
72+
new Type\FileType($this->translator),
7373
new Type\ButtonType(),
7474
new Type\SubmitType(),
7575
new Type\ResetType(),

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormFactoryBuilder.php
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111

1212
namespace Symfony\Component\Form;
1313

14+
use Symfony\Component\Form\Extension\Core\CoreExtension;
15+
1416
/**
1517
* The default implementation of FormFactoryBuilderInterface.
1618
*
1719
* @author Bernhard Schussek <bschussek@gmail.com>
1820
*/
1921
class FormFactoryBuilder implements 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+
public function __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 ($extensions as $extension) {
163+
if ($extension instanceof CoreExtension) {
164+
$hasCoreExtension = true;
165+
break;
166+
}
167+
}
168+
169+
if (!$hasCoreExtension) {
170+
array_unshift($extensions, new CoreExtension());
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 = new FormTypeGuesserChain($this->typeGuessers);

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Forms.php
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Form;
1313

14-
use Symfony\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
public static function createFormFactoryBuilder()
107105
{
108-
$builder = new FormFactoryBuilder();
109-
$builder->addExtension(new CoreExtension());
110-
111-
return $builder;
106+
return new FormFactoryBuilder(true);
112107
}
113108

114109
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.