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:
parent
ede66604d7
commit
07d90f987e
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Doctrine\Form\Type;
|
namespace Symfony\Bridge\Doctrine\Form\Type;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||||
use Doctrine\Common\Persistence\ObjectManager;
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
|
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)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
if ($options['multiple']) {
|
if ($options['multiple'] && interface_exists(Collection::class)) {
|
||||||
$builder
|
$builder
|
||||||
->addEventSubscriber(new MergeDoctrineCollectionListener())
|
->addEventSubscriber(new MergeDoctrineCollectionListener())
|
||||||
->addViewTransformer(new CollectionToArrayTransformer(), true)
|
->addViewTransformer(new CollectionToArrayTransformer(), true)
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1.3",
|
"php": "^7.1.3",
|
||||||
"doctrine/collections": "~1.0",
|
|
||||||
"doctrine/event-manager": "~1.0",
|
"doctrine/event-manager": "~1.0",
|
||||||
"doctrine/persistence": "~1.0",
|
"doctrine/persistence": "~1.0",
|
||||||
"symfony/contracts": "^1.0",
|
"symfony/contracts": "^1.0",
|
||||||
@ -39,6 +38,7 @@
|
|||||||
"symfony/translation": "~3.4|~4.0",
|
"symfony/translation": "~3.4|~4.0",
|
||||||
"doctrine/annotations": "~1.0",
|
"doctrine/annotations": "~1.0",
|
||||||
"doctrine/cache": "~1.6",
|
"doctrine/cache": "~1.6",
|
||||||
|
"doctrine/collections": "~1.0",
|
||||||
"doctrine/data-fixtures": "1.0.*",
|
"doctrine/data-fixtures": "1.0.*",
|
||||||
"doctrine/dbal": "~2.4",
|
"doctrine/dbal": "~2.4",
|
||||||
"doctrine/orm": "^2.4.5",
|
"doctrine/orm": "^2.4.5",
|
||||||
|
Reference in New Issue
Block a user