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

DependencyFactory::getEventDispatcher triggers a deprecation #1348

Open
VincentLanglet opened this issue Aug 11, 2023 · 6 comments
Open

DependencyFactory::getEventDispatcher triggers a deprecation #1348

VincentLanglet opened this issue Aug 11, 2023 · 6 comments

Comments

@VincentLanglet
Copy link
Contributor

Bug Report

Q A
BC Break no
Version x.y.z

Summary

DependencyFactory::getEventDispatcher is implemented this way:

return $this->getDependency(EventDispatcher::class, function (): EventDispatcher {
    return new EventDispatcher(
        $this->getConnection(),
        $this->getConnection()->getEventManager(),
    );
});

but Connection::getEventManager is deprecated by dbal since doctrine/dbal#5784

Not sure how to fix this @greg0ire @derrabus

@derrabus
Copy link
Member

Deprecate calling fromConnection() without passing an event manager?

@VincentLanglet
Copy link
Contributor Author

Seems like EntityManagerInterface::getEventManager exists ; I'll try this instead.

@derrabus
Copy link
Member

Seems like EntityManagerInterface::getEventManager exists ; I'll try this instead.

Yes, but that'll only work if you have an entity manager. You can use migrations with a connection only.

@stof
Copy link
Member

stof commented Aug 11, 2023

fromConnection should indeed allow passing an EventManager explicitly, using Connection::getEventManager only as fallback (triggering a deprecation telling you to pass an EventManager explicitly).
fromEntityManager would register the EventManager using the ORM EventManager.

DependencyFactory::getEventDispatcher would then use a DependencyFactory::getEventManager method reading the configured event manager.

@VincentLanglet
Copy link
Contributor Author

DoctrineCommand is doing DependencyFactory::fromConnection does it mean we have to add EventManager to the constructor of all doctrine command ?

@stof
Copy link
Member

stof commented Aug 11, 2023

To be compatible with CLI commands, we might need a concept of an event manager loader instead of passing directly an event 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

3 participants