public function __invoke(ContainerInterface $container, $requestedName, array $options = NULL) { /** @var RouteMatch $routeMatch */ $routeMatch = $container->get('Application')->getMvcEvent()->getRouteMatch(); $name = $routeMatch->getParam('name', 'default'); $migrationConfig = $container->get('config')['migrations'][$name]; $prefix = isset($migrationConfig['prefix']) ? $migrationConfig['prefix'] : ''; /** @var Migration $migration */ $migration = $container->get('migrations.migration.' . $name); $migration->changeMigrationPrefix($prefix); /** @var MigrationSkeletonGenerator $generator */ $generator = $container->get('migrations.skeleton-generator.' . $name); $controller = new MigrateController(); $controller->setMigration($migration); $controller->setSkeletonGenerator($generator); return $controller; }
/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { if ($serviceLocator instanceof AbstractPluginManager) { $serviceLocator = $serviceLocator->getServiceLocator(); } /** @var RouteMatch $routeMatch */ $routeMatch = $serviceLocator->get('Application')->getMvcEvent()->getRouteMatch(); $name = $routeMatch->getParam('name', 'default'); /** @var Migration $migration */ $migration = $serviceLocator->get('migrations.migration.' . $name); /** @var MigrationSkeletonGenerator $generator */ $generator = $serviceLocator->get('migrations.skeleton-generator.' . $name); $controller = new MigrateController(); $controller->setMigration($migration); $controller->setSkeletonGenerator($generator); return $controller; }