1111
1212namespace Symfony \Bridge \Doctrine \Form \Type ;
1313
14- use Doctrine \Common \Persistence \ManagerRegistry ;
15- use Doctrine \Common \Persistence \ObjectManager ;
14+ use Doctrine \Common \Persistence \ManagerRegistry as LegacyManagerRegistry ;
15+ use Doctrine \Common \Persistence \ObjectManager as LegacyObjectManager ;
16+ use Doctrine \Persistence \ManagerRegistry ;
17+ use Doctrine \Persistence \ObjectManager ;
1618use Symfony \Bridge \Doctrine \Form \ChoiceList \DoctrineChoiceLoader ;
1719use Symfony \Bridge \Doctrine \Form \ChoiceList \EntityLoaderInterface ;
1820use Symfony \Bridge \Doctrine \Form \ChoiceList \IdReader ;
@@ -99,7 +101,10 @@ public function getQueryBuilderPartsForCachingHash($queryBuilder)
99101 return false ;
100102 }
101103
102- public function __construct (ManagerRegistry $ registry )
104+ /**
105+ * @param ManagerRegistry|LegacyManagerRegistry $registry
106+ */
107+ public function __construct ($ registry )
103108 {
104109 $ this ->registry = $ registry ;
105110 }
@@ -194,9 +199,8 @@ public function configureOptions(OptionsResolver $resolver)
194199 };
195200
196201 $ emNormalizer = function (Options $ options , $ em ) {
197- /* @var ManagerRegistry $registry */
198202 if (null !== $ em ) {
199- if ($ em instanceof ObjectManager) {
203+ if ($ em instanceof ObjectManager || $ em instanceof LegacyObjectManager ) {
200204 return $ em ;
201205 }
202206
@@ -262,7 +266,7 @@ public function configureOptions(OptionsResolver $resolver)
262266 $ resolver ->setNormalizer ('query_builder ' , $ queryBuilderNormalizer );
263267 $ resolver ->setNormalizer ('id_reader ' , $ idReaderNormalizer );
264268
265- $ resolver ->setAllowedTypes ('em ' , ['null ' , 'string ' , ' Doctrine\Common\Persistence\ ObjectManager' ]);
269+ $ resolver ->setAllowedTypes ('em ' , ['null ' , 'string ' , ObjectManager::class, LegacyObjectManager::class ]);
266270 }
267271
268272 /**
@@ -273,7 +277,7 @@ public function configureOptions(OptionsResolver $resolver)
273277 *
274278 * @return EntityLoaderInterface
275279 */
276- abstract public function getLoader (ObjectManager $ manager , $ queryBuilder , $ class );
280+ abstract public function getLoader (LegacyObjectManager $ manager , $ queryBuilder , $ class );
277281
278282 public function getParent ()
279283 {
0 commit comments