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

Fix the configurability of CoreExtension deps in standalone usage #30979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function loadTypes()
new Type\TimeType(),
new Type\TimezoneType(),
new Type\UrlType(),
new Type\FileType(),
new Type\FileType($this->translator),
new Type\ButtonType(),
new Type\SubmitType(),
new Type\ResetType(),
Expand Down
27 changes: 27 additions & 0 deletions 27 src/Symfony/Component/Form/FormFactoryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@

namespace Symfony\Component\Form;

use Symfony\Component\Form\Extension\Core\CoreExtension;

/**
* The default implementation of FormFactoryBuilderInterface.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class FormFactoryBuilder implements FormFactoryBuilderInterface
{
private $forceCoreExtension;

/**
* @var ResolvedFormTypeFactoryInterface
*/
Expand All @@ -43,6 +47,14 @@ class FormFactoryBuilder implements FormFactoryBuilderInterface
*/
private $typeGuessers = [];

/**
* @param bool $forceCoreExtension
*/
public function __construct($forceCoreExtension = false)
Copy link
Member

@chalasr chalasr Apr 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpdoc should be replaced by a typehint when merging up to master

{
$this->forceCoreExtension = $forceCoreExtension;
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -144,6 +156,21 @@ public function getFormFactory()
{
$extensions = $this->extensions;

if ($this->forceCoreExtension) {
$hasCoreExtension = false;

foreach ($extensions as $extension) {
if ($extension instanceof CoreExtension) {
xabbuh marked this conversation as resolved.
Show resolved Hide resolved
$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);
Expand Down
7 changes: 1 addition & 6 deletions 7 src/Symfony/Component/Form/Forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Symfony\Component\Form;

use Symfony\Component\Form\Extension\Core\CoreExtension;

/**
* Entry point of the Form component.
*
Expand Down Expand Up @@ -105,10 +103,7 @@ public static function createFormFactory()
*/
public static function createFormFactoryBuilder()
{
$builder = new FormFactoryBuilder();
$builder->addExtension(new CoreExtension());

return $builder;
return new FormFactoryBuilder(true);
}

/**
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.