DefaultRepositoryFactory create repository using EntityManager instead of ManagerRegistry #6453

Open
opened 2026-01-22 15:33:30 +01:00 by admin · 1 comment
Owner

Originally created by @vsilvestre-accenture on GitHub (Apr 22, 2020).

Hi ! :)
I just used TypeTestCase of Symfony, that use a factory in order to test form.
And I just ran into an issue of typing.

TypeError: Argument 1 passed to Picwic\ModelBundle\Repository\CommercialOperationReasonRepository::__construct() must implement interface Doctrine\Common\Persistence\ManagerRegistry, instance of Doctrine\ORM\EntityManager given, called in /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php on line 68

It's due to this line.
dafe298ce5/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php (L68)

Originally created by @vsilvestre-accenture on GitHub (Apr 22, 2020). Hi ! :) I just used TypeTestCase of Symfony, that use a factory in order to test form. And I just ran into an issue of typing. `TypeError: Argument 1 passed to Picwic\ModelBundle\Repository\CommercialOperationReasonRepository::__construct() must implement interface Doctrine\Common\Persistence\ManagerRegistry, instance of Doctrine\ORM\EntityManager given, called in /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php on line 68` It's due to this line. https://github.com/doctrine/orm/blob/dafe298ce5d0b995ebe1746670704c0a35868a6a/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php#L68
Author
Owner

@SenseException commented on GitHub (Apr 22, 2020):

Hi @vsilvestre-accenture. What does the constructor of CommercialOperationReasonRepository looks like and which versions of Doctrine ORM and Persistance do you use? There was a change of namespaces in Persistance where Doctrine\Common\Persistence became Doctrine\Persistence even though there should aliases that catch the renaming.

@SenseException commented on GitHub (Apr 22, 2020): Hi @vsilvestre-accenture. What does the constructor of `CommercialOperationReasonRepository` looks like and which versions of Doctrine ORM and Persistance do you use? There was a change of namespaces in Persistance where `Doctrine\Common\Persistence` became `Doctrine\Persistence` even though there should aliases that catch the renaming.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6453