Move doctrine/collections to an optional dep in doctrine-bridge

The EntityType does not need to convert the array to a collection if
the project does not care about using doctrine/collections. So this
can become an optional dependency.
This commit is contained in:
Christophe Coevoet 2019-04-06 19:22:14 +02:00
parent ede66604d7
commit 07d90f987e
2 changed files with 3 additions and 2 deletions

View File

@ -11,6 +11,7 @@
namespace Symfony\Bridge\Doctrine\Form\Type;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
@ -107,7 +108,7 @@ abstract class DoctrineType extends AbstractType implements ResetInterface
public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($options['multiple']) {
if ($options['multiple'] && interface_exists(Collection::class)) {
$builder
->addEventSubscriber(new MergeDoctrineCollectionListener())
->addViewTransformer(new CollectionToArrayTransformer(), true)

View File

@ -17,7 +17,6 @@
],
"require": {
"php": "^7.1.3",
"doctrine/collections": "~1.0",
"doctrine/event-manager": "~1.0",
"doctrine/persistence": "~1.0",
"symfony/contracts": "^1.0",
@ -39,6 +38,7 @@
"symfony/translation": "~3.4|~4.0",
"doctrine/annotations": "~1.0",
"doctrine/cache": "~1.6",
"doctrine/collections": "~1.0",
"doctrine/data-fixtures": "1.0.*",
"doctrine/dbal": "~2.4",
"doctrine/orm": "^2.4.5",