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?
Support Question
I have to support a custom Symfony bundle that depends on
doctrine/migrationsanddoctrine/dbal. Currently I am implementing forward compatibility with DBAL 4, which famously removed extension via Doctrine’sEventManager.Current
DependencyFactoryindoctrine/migrationsfalls back to\Doctrine\Common\EventManageron DBAL v4:One of the central features of my bundle listens to migration events (
onMigrationsVersionExecuted, etc.) and registers a subscriber by tagging it withdoctrine.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
DependencyFactoryat runtime to register my custom event subscriber, butDependencyFactory::getEventManageris 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 dudEventManagerthat dispatches events, but never registers any listeners.Is there a way to subscribe to migration events on DBAL 4 that I am missing?