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

Why ObjectManager instead of EntityManagerInterface? #429

Open
aivchen opened this issue Feb 17, 2023 · 2 comments
Open

Why ObjectManager instead of EntityManagerInterface? #429

aivchen opened this issue Feb 17, 2023 · 2 comments

Comments

@aivchen
Copy link
Contributor

aivchen commented Feb 17, 2023

ReferenceRepository depends on ObjectManager interface:

public function __construct(ObjectManager $manager)

But futher in code getUnitOfWork method is called:

$uow = $this->manager->getUnitOfWork();

\Doctrine\Persistence\ObjectManager interface doesn't contain this method. But \Doctrine\ORM\EntityManagerInterface contains.

Could you tell me, why there is a dependency on ObjectManager instead of EntityManagerInterface?

Thanks!

@stof
Copy link
Member

stof commented Feb 17, 2023

Because doctrine/data-fixtures is not specific to the ORM. The code supports multiple Doctrine O*M projects.

But it is true that the ReferenceRepository does not work with any implementation of Doctrine\Persistence\ObjectManager, only with implementations in those projects.

@aivchen
Copy link
Contributor Author

aivchen commented Feb 17, 2023

Ok, got it, thanks.

Then is my doc-annotation correct in this case?

    /**
     * Currently used object manager
     *
     * @var \Doctrine\ORM\EntityManagerInterface|\Doctrine\ODM\MongoDB\DocumentManager|\Doctrine\ODM\PHPCR\DocumentManagerInterface
     */
    private $manager;

    public function __construct(ObjectManager $manager)
    {
        $this->manager = $manager;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants