Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f3a0555

Browse files
committed
minor #30924 Move doctrine/collections to an optional dep in doctrine-bridge (stof)
This PR was merged into the 4.3-dev branch. Discussion ---------- Move doctrine/collections to an optional dep in doctrine-bridge | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | 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. The goal here is to reduce the dependencies of DoctrineBundle when using it in DBAL-only mode. doctrine/persistence still brings a bunch of unwanted dependencies for a DBAL-only project, but this requires work on the Doctrine side (we discussed it with @alcaeus) as the ConnectionRegistry is part of it. Moving it to an optional dependency in the bridge will probably come in 6 months instead. And doctrine-cache-bundle also brings some, but that's already in the work of being removed from DoctrineBundle 2.0. Commits ------- 07d90f9 Move doctrine/collections to an optional dep in doctrine-bridge
2 parents f551f2d + 07d90f9 commit f3a0555

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Form\Type;
1313

14+
use Doctrine\Common\Collections\Collection;
1415
use Doctrine\Common\Persistence\ManagerRegistry;
1516
use Doctrine\Common\Persistence\ObjectManager;
1617
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
@@ -107,7 +108,7 @@ public function __construct(ManagerRegistry $registry)
107108

108109
public function buildForm(FormBuilderInterface $builder, array $options)
109110
{
110-
if ($options['multiple']) {
111+
if ($options['multiple'] && interface_exists(Collection::class)) {
111112
$builder
112113
->addEventSubscriber(new MergeDoctrineCollectionListener())
113114
->addViewTransformer(new CollectionToArrayTransformer(), true)

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
],
1818
"require": {
1919
"php": "^7.1.3",
20-
"doctrine/collections": "~1.0",
2120
"doctrine/event-manager": "~1.0",
2221
"doctrine/persistence": "~1.0",
2322
"symfony/contracts": "^1.0",
@@ -39,6 +38,7 @@
3938
"symfony/translation": "~3.4|~4.0",
4039
"doctrine/annotations": "~1.0",
4140
"doctrine/cache": "~1.6",
41+
"doctrine/collections": "~1.0",
4242
"doctrine/data-fixtures": "1.0.*",
4343
"doctrine/dbal": "~2.4",
4444
"doctrine/orm": "^2.4.5",

0 commit comments

Comments
 (0)