Skip to content

Commit 1f3ea0f

Browse files
committed
Use ObjectManager interface instead of EntityManager
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.
1 parent 6dac13b commit 1f3ea0f

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)