public function downAction() { $installed = $this->migrationService->getInstalledMigrations(); $this->console->writeLine(' Installed migrations:'); if (!$this->showMigrationList($installed)) { return; } try { if ($oneMigration = $this->getRequest()->getParam('migration', null)) { if (isset($installed[$oneMigration])) { $this->migrationService->uninstallMigration($oneMigration, $this->interactive); } else { $this->console->writeLine(sprintf(' "%s" migration not installed.', $oneMigration), ColorInterface::RED); } } else { foreach (array_reverse($installed) as $name => $migration) { $this->migrationService->uninstallMigration($name, $this->interactive); } } } catch (StopMigrationException $e) { $this->console->writeLine($e->getMessage(), ColorInterface::RED); } }
/** * The __invoke method is called when a script tries to call an object as a function. * * @param ContainerInterface $container * @param string $name * @param array $options * @return mixed */ function __invoke(ContainerInterface $container, $name, array $options = null) { $instance = new MigrationService(); return $instance->setDbAdapter($container->get('Zend\\Db\\Adapter\\Adapter'))->setMigrationPluginManager($container->get('MigrationPluginManager'))->setConsole($container->get('Console')); }