bug #15637 Use ObjectManager interface instead of EntityManager (gnat42)
This PR was merged into the 2.3 branch.
Discussion
----------
Use ObjectManager interface instead of EntityManager
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
If you use the EntityManager Decorator pattern that doctrine provides
then simply specifying a query_builder closure where your decorated
em is used fails as it isn't an instance of Doctrine\ORM\EntityManager.
Testing against the ObjectManager interface fixes the issue.
Commits
-------
1f3ea0f
Use ObjectManager interface instead of EntityManager
This commit is contained in:
commit
d87db39aa1
@ -14,7 +14,7 @@ namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
|
|||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getting Entities through the ORM QueryBuilder.
|
* Getting Entities through the ORM QueryBuilder.
|
||||||
@ -35,7 +35,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
|||||||
* Construct an ORM Query Builder Loader.
|
* Construct an ORM Query Builder Loader.
|
||||||
*
|
*
|
||||||
* @param QueryBuilder|\Closure $queryBuilder
|
* @param QueryBuilder|\Closure $queryBuilder
|
||||||
* @param EntityManager $manager
|
* @param ObjectManager $manager
|
||||||
* @param string $class
|
* @param string $class
|
||||||
*
|
*
|
||||||
* @throws UnexpectedTypeException
|
* @throws UnexpectedTypeException
|
||||||
@ -49,8 +49,8 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($queryBuilder instanceof \Closure) {
|
if ($queryBuilder instanceof \Closure) {
|
||||||
if (!$manager instanceof EntityManager) {
|
if (!$manager instanceof ObjectManager) {
|
||||||
throw new UnexpectedTypeException($manager, 'Doctrine\ORM\EntityManager');
|
throw new UnexpectedTypeException($manager, 'Doctrine\Common\Persistence\ObjectManager');
|
||||||
}
|
}
|
||||||
|
|
||||||
$queryBuilder = $queryBuilder($manager->getRepository($class));
|
$queryBuilder = $queryBuilder($manager->getRepository($class));
|
||||||
|
Reference in New Issue
Block a user