Closed IonBazan closed 2 years ago
I guess we should introduce a compiler pass and inject the proper service instead
It could actually be a set of services - one might have all 3 doctrine libs installed.
I don't get why this doesn't work in mapping.xml
<service id="vich_uploader.metadata_driver.annotation" class="Vich\UploaderBundle\Metadata\Driver\AnnotationDriver" public="false">
<argument key="$reader" type="service" id="vich_uploader.metadata.reader" />
<argument key="$managerRegistry" type="service" id="Doctrine\Persistence\ManagerRegistry" />
</service>
resulting in error Cannot instantiate interface Doctrine\Persistence\ManagerRegistry
I got why: Doctrine\Persistence\ManagerRegistry
is too high in the stack to be injected, and every manager (orm, odm, phpcr) have to be configured (connection parameter, db name, etc), that's why we have doctrine_mongodb
, doctrine_phpcr
and doctrine
services Id, all implementing Doctrine\Persistence\ManagerRegistry
.
We need a compiler pass that looks for doctrine_mongodb
, doctrine_phpcr
and/or doctrine
services id and inject all Manager found to Vich\UploaderBundle\Metadata\Driver\AnnotationDriver
as an array of Manager.
Pushed a PR, tested with a simple Symfony app with both ORM and ODM bundles enabled
BC Break Report
Summary
This bundle relies on
doctrine
service when Doctrine ORM Bundle is not installed (eg. Doctrine MongoDB ODM is used instead).Introduced in #1305 (see discussion there for reference)
Previous behavior
This bundle did not require Doctrine ORM Bundle to be installed.
Current behavior
Following error is thrown if Doctrine Bundle is not installed:
How to reproduce
Upgrade from v1.20.0 to v1.21.0 and run
bin/console c:c
.