eventLogger = $eventLogger; } public function onMigrationsMigrated(MigrationsEventArgs $args): void { //Dont do anything if this was a dry run if ($args->isDryRun()) { return; } //Save the version after the migration $this->new_version = $args->getConfiguration()->getCurrentVersion(); //After everything is done, write the results to DB log $this->old_version = empty($this->old_version) ? 'legacy/empty' : $this->old_version; $this->new_version = empty($this->new_version) ? 'unknown' : $this->new_version; try { $log = new DatabaseUpdatedLogEntry($this->old_version, $this->new_version); $this->eventLogger->logAndFlush($log); } catch (\Throwable $exception) { //Ignore any exception occuring here... } } public function onMigrationsMigrating(MigrationsEventArgs $args): void { // Save the version before any migration if (null === $this->old_version) { $this->old_version = $args->getConfiguration()->getCurrentVersion(); } } public function getSubscribedEvents() { return [ Events::onMigrationsMigrated, Events::onMigrationsMigrating, ]; } }