Skip to content

Commit d87db39

Browse files
committed
bug symfony#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
2 parents 50afff1 + 1f3ea0f commit d87db39

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1515
use Doctrine\ORM\QueryBuilder;
1616
use Doctrine\DBAL\Connection;
17-
use Doctrine\ORM\EntityManager;
17+
use Doctrine\Common\Persistence\ObjectManager;
1818

1919
/**
2020
* Getting Entities through the ORM QueryBuilder.
@@ -35,7 +35,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
3535
* Construct an ORM Query Builder Loader.
3636
*
3737
* @param QueryBuilder|\Closure $queryBuilder
38-
* @param EntityManager $manager
38+
* @param ObjectManager $manager
3939
* @param string $class
4040
*
4141
* @throws UnexpectedTypeException
@@ -49,8 +49,8 @@ public function __construct($queryBuilder, $manager = null, $class = null)
4949
}
5050

5151
if ($queryBuilder instanceof \Closure) {
52-
if (!$manager instanceof EntityManager) {
53-
throw new UnexpectedTypeException($manager, 'Doctrine\ORM\EntityManager');
52+
if (!$manager instanceof ObjectManager) {
53+
throw new UnexpectedTypeException($manager, 'Doctrine\Common\Persistence\ObjectManager');
5454
}
5555

5656
$queryBuilder = $queryBuilder($manager->getRepository($class));

0 commit comments

Comments
 (0)