-
-
Notifications
You must be signed in to change notification settings - Fork 397
Description
| Q | A |
|---|---|
| Version | 3.9.4 |
Support Question
I have to support a custom Symfony bundle that depends on doctrine/migrations and doctrine/dbal. Currently I am implementing forward compatibility with DBAL 4, which famously removed extension via Doctrine’s EventManager.
Current DependencyFactory in doctrine/migrations falls back to \Doctrine\Common\EventManager on DBAL v4:
if (method_exists(Connection::class, 'getEventManager')) {
// DBAL < 4
return $this->eventManager = $this->getConnection()->getEventManager();
}
return $this->eventManager = new EventManager();One of the central features of my bundle listens to migration events (onMigrationsVersionExecuted, etc.) and registers a subscriber by tagging it with doctrine.event_listener. On DBAL 4 this breaks because $this->eventManager = new EventManager() is a simpleton that is not aware of the Symfony container.
Naturally, I wanted to dig into DependencyFactory at runtime to register my custom event subscriber, but DependencyFactory::getEventManager is private and as far as I see on DBAL 4 there is simply no way to get to that $this->eventManager = new EventManager() to register listeners/subscribers. Instead, it seems I am stuck with a dud EventManager that dispatches events, but never registers any listeners.
Is there a way to subscribe to migration events on DBAL 4 that I am missing?