src/Graviton/MigrationBundle/Command/MongodbMigrateCommand.php
public function execute(InputInterface $input, OutputInterface $output)
    {
        // graviton root
        $baseDir = __DIR__.'/../../../';

        // vendorized? - go back some more..
        if (strpos($baseDir, '/vendor/') !== false) {
            $baseDir .= '../../../';
        }

        $this->finder
            ->in($baseDir)
            ->path('Resources/config')
            ->name('/migrations.(xml|yml)/')
            ->files();

        foreach ($this->finder as $file) {
            if (!$file->isFile()) {
                continue;
            }

            $output->writeln('Found '.$file->getRelativePathname());

            $command = $this->getApplication()->find('mongodb:migrations:migrate');

            $helperSet = $command->getHelperSet();
            $helperSet->set($this->documentManager, 'dm');
            $command->setHelperSet($helperSet);

            $configuration = $this->getConfiguration($file->getPathname(), $output);
            self::injectContainerToMigrations($this->container, $configuration->getMigrations());
            $command->setMigrationConfiguration($configuration);

            $arguments = $input->getArguments();
            $arguments['command'] = 'mongodb:migrations:migrate';
            $arguments['--configuration'] = $file->getPathname();

            $migrateInput = new ArrayInput($arguments);
            $migrateInput->setInteractive($input->isInteractive());
            $returnCode = $command->run($migrateInput, $output);

            if ($returnCode !== 0) {
                $this->errors[] = sprintf(
                    'Calling mongodb:migrations:migrate failed for %s',
                    $file->getRelativePathname()
                );
            }
        }

        if (!empty($this->errors)) {
            $output->writeln(
                sprintf('<error>%s</error>', implode(PHP_EOL, $this->errors))
            );
            return -1;
        }

        return 0;
    }
public function execute(InputInterface $input, OutputInterface $output)
    {
        // graviton root
        $baseDir = __DIR__.'/../../../';

        // vendorized? - go back some more..
        if (strpos($baseDir, '/vendor/') !== false) {
            $baseDir .= '../../../';
        }

        $this->finder
            ->in($baseDir)
            ->path('Resources/config')
            ->name('/migrations.(xml|yml)/')
            ->files();

        foreach ($this->finder as $file) {
            if (!$file->isFile()) {
                continue;
            }

            $output->writeln('Found '.$file->getRelativePathname());

            $command = $this->getApplication()->find('mongodb:migrations:migrate');

            $helperSet = $command->getHelperSet();
            $helperSet->set($this->documentManager, 'dm');
            $command->setHelperSet($helperSet);

            $configuration = $this->getConfiguration($file->getPathname(), $output);
            self::injectContainerToMigrations($this->container, $configuration->getMigrations());
            $command->setMigrationConfiguration($configuration);

            $arguments = $input->getArguments();
            $arguments['command'] = 'mongodb:migrations:migrate';
            $arguments['--configuration'] = $file->getPathname();

            $migrateInput = new ArrayInput($arguments);
            $migrateInput->setInteractive($input->isInteractive());
            $returnCode = $command->run($migrateInput, $output);

            if ($returnCode !== 0) {
                $this->errors[] = sprintf(
                    'Calling mongodb:migrations:migrate failed for %s',
                    $file->getRelativePathname()
                );
            }
        }

        if (!empty($this->errors)) {
            $output->writeln(
                sprintf('<error>%s</error>', implode(PHP_EOL, $this->errors))
            );
            return -1;
        }

        return 0;
    }
public function execute ( InputInterface $ input , OutputInterface $ output ) { // graviton root $ baseDir = __DIR__ . '/../../../' ; // vendorized? - go back some more.. if ( strpos ( $ baseDir , '/vendor/' ) !== false ) { $ baseDir .= '../../../' ; } $ this -> finder -> in ( $ baseDir ) -> path ( 'Resources/config' ) -> name ( '/migrations.(xml|yml)/' ) -> files ( ) ; foreach ( $ this -> finder as $ file ) { if ( ! $ file -> isFile ( ) ) { continue ; } $ output -> writeln ( 'Found ' . $ file -> getRelativePathname ( ) ) ; $ command = $ this -> getApplication ( ) -> find ( 'mongodb:migrations:migrate' ) ; $ helperSet = $ command -> getHelperSet ( ) ; $ helperSet -> set ( $ this -> documentManager , 'dm' ) ; $ command -> setHelperSet ( $ helperSet ) ; $ configuration = $ this -> getConfiguration ( $ file -> getPathname ( ) , $ output ) ; self :: injectContainerToMigrations ( $ this -> container , $ configuration -> getMigrations ( ) ) ; $ command -> setMigrationConfiguration ( $ configuration ) ; $ arguments = $ input -> getArguments ( ) ; $ arguments [ 'command' ] = 'mongodb:migrations:migrate' ; $ arguments [ '--configuration' ] = $ file -> getPathname ( ) ; $ migrateInput = new ArrayInput ( $ arguments ) ; $ migrateInput -> setInteractive ( $ input -> isInteractive ( ) ) ; $ returnCode = $ command -> run ( $ migrateInput , $ output ) ; if ( $ returnCode !== 0 ) { $ this -> errors [ ] = sprintf ( 'Calling mongodb:migrations:migrate failed for %s' , $ file -> getRelativePathname ( ) ) ; } } if ( ! empty ( $ this -> errors ) ) { $ output -> writeln ( sprintf ( '<error>%s</error>' , implode ( PHP_EOL , $ this -> errors ) ) ) ; return - 1 ; } return 0 ; }
call execute on found commands

@param InputInterface  $input  user input
@param OutputInterface $output command output

@return void
call execute on found commands