-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the configurability of CoreExtension deps in standalone usage
- Loading branch information
1 parent
8421b91
commit 657318b
Showing
3 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,13 +11,17 @@ | |
|
||
namespace Symfony\Component\Form; | ||
|
||
use Symfony\Component\Form\Extension\Core\CoreExtension; | ||
|
||
/** | ||
* The default implementation of FormFactoryBuilderInterface. | ||
* | ||
* @author Bernhard Schussek <[email protected]> | ||
*/ | ||
class FormFactoryBuilder implements FormFactoryBuilderInterface | ||
{ | ||
private $forceCoreExtension; | ||
|
||
/** | ||
* @var ResolvedFormTypeFactoryInterface | ||
*/ | ||
|
@@ -43,6 +47,14 @@ class FormFactoryBuilder implements FormFactoryBuilderInterface | |
*/ | ||
private $typeGuessers = []; | ||
|
||
/** | ||
* @param bool $forceCoreExtension | ||
*/ | ||
public function __construct($forceCoreExtension = false) | ||
{ | ||
$this->forceCoreExtension = $forceCoreExtension; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
|
@@ -144,6 +156,21 @@ public function getFormFactory() | |
{ | ||
$extensions = $this->extensions; | ||
|
||
if ($this->forceCoreExtension) { | ||
$hasCoreExtension = false; | ||
|
||
foreach ($extensions as $extension) { | ||
if ($extension instanceof CoreExtension) { | ||
$hasCoreExtension = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!$hasCoreExtension) { | ||
array_unshift($extensions, new CoreExtension()); | ||
} | ||
} | ||
|
||
if (\count($this->types) > 0 || \count($this->typeExtensions) > 0 || \count($this->typeGuessers) > 0) { | ||
if (\count($this->typeGuessers) > 1) { | ||
$typeGuesser = new FormTypeGuesserChain($this->typeGuessers); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters