Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository type does not match with ManagerRegistry #23

Closed
soullivaneuh opened this issue Jan 24, 2018 · 5 comments
Closed

Repository type does not match with ManagerRegistry #23

soullivaneuh opened this issue Jan 24, 2018 · 5 comments

Comments

@soullivaneuh
Copy link

This PHP code part is valid:

$user = $this->getDoctrine()->getRepository(User::class)->find(
    $this->request->query->get('id')
);

$this->getDoctrine() return a ManagerRegistry instance.

But the final $user does not seems to be typed:

Call to an undefined method object::getUsername().

Using the EntityManagerInterface directly make things working.

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Jan 25, 2018 via email

@hkdobrev
Copy link
Contributor

@ondrejmirtes Using the interfaces decouples your code from the ORM a bit and you could add a custom implementation using the interface as an extension point. The interfaces are also the only common thing between the ORM and the ODM so if you want to switch a piece of logic to be persisted in MongoDB, you wouldn't want your code to be dependent on using the ORM.

@Majkl578
Copy link
Contributor

There is also bunch of methods that you simply can't use with just ObjectRepository. Unfortunately there is no interface in ORM 2.x, but see https://github.com/doctrine/doctrine2/pull/6871/files#diff-8a10ca9860c185f1c82078d9bbaa27d5R1.

@ondrejmirtes
Copy link
Member

This now works on master.

@github-actions
Copy link

github-actions bot commented May 2, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants