/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->get('entity_manager');
     $helperSet = new HelperSet();
     $helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
     $helperSet->set(new EntityManagerHelper($em), 'em');
     $arguments = array();
     if ($input->getArgument('version')) {
         $arguments['version'] = $input->getArgument('version');
     }
     if ($input->getOption('add')) {
         $arguments['--add'] = $input->getOption('add');
     }
     if ($input->getOption('delete')) {
         $arguments['--delete'] = $input->getOption('delete');
     }
     if ($input->getOption('all')) {
         $arguments['--all'] = $input->getOption('all');
     }
     if ($input->getOption('range-from')) {
         $arguments['--range-from'] = $input->getOption('range-from');
     }
     if ($input->getOption('range-to')) {
         $arguments['--range-to'] = $input->getOption('range-to');
     }
     $configDir = $this->get('config')->get('[directories][config_dir]');
     $arguments['--configuration'] = $configDir . '/migrations.yml';
     $command = new VersionCommand();
     $command->setHelperSet($helperSet);
     $returnCode = $command->run(new ArrayInput($arguments), $output);
     return $returnCode;
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em'));
     $configuration = $this->getMigrationConfiguration($input, $output);
     DoctrineCommand::configureMigrations($this->application->getKernel()->getContainer(), $configuration);
     parent::execute($input, $output);
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var \Pimple\Container $container */
     $container = $this->getHelper('pimple')->getContainer();
     $this->setApplicationEntityManager($container, $this->getApplication(), $input->getOption('em'));
     $configuration = $this->getMigrationConfiguration($input, $output);
     $this->configureMigrations($container, $configuration);
     parent::execute($input, $output);
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     // EM and DB options cannot be set at same time
     if (null !== $input->getOption('em') && null !== $input->getOption('db')) {
         throw new \InvalidArgumentException('Cannot set both "em" and "db" for command execution.');
     }
     Helper\DoctrineCommandHelper::setApplicationHelper($this->getApplication(), $input);
     $configuration = $this->getMigrationConfiguration($input, $output);
     DoctrineCommand::configureMigrations($this->getApplication()->getKernel()->getContainer(), $configuration);
     parent::execute($input, $output);
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var \Symfony\Bundle\FrameworkBundle\Console\Application $app */
     $app = $this->getApplication();
     /** @var ContainerInterface $container */
     $container = $app->getKernel()->getContainer();
     $this->setMigrationConfiguration($this->getBasicConfiguration($container, $output));
     $configuration = $this->getMigrationConfiguration($input, $output);
     $this->configureMigrations($container, $configuration);
     parent::execute($input, $output);
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em'));
     parent::execute($input, $output);
 }
Example #7
0
use Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Del\Common\ContainerService;
use Del\Common\Config\DbCredentials;
$credentials = new DbCredentials();
$container = ContainerService::getInstance()->setDbCredentials($credentials)->addEntityPath('src/Entity')->getContainer();
// Fetch the entity Manager
$em = $container['doctrine.entity_manager'];
// Create the helperset
$helperSet = ConsoleRunner::createHelperSet($em);
$helperSet->set(new \Symfony\Component\Console\Helper\DialogHelper(), 'dialog');
/** Migrations setup */
$configuration = new Configuration($em->getConnection());
$configuration->setMigrationsDirectory('migrations');
$configuration->setMigrationsNamespace('migrations');
$configuration->setMigrationsTableName('Migration');
//$delmigrate = new Migration();
$diff = new DiffCommand();
$exec = new ExecuteCommand();
$gen = new GenerateCommand();
$migrate = new MigrateCommand();
$status = new StatusCommand();
$ver = new VersionCommand();
$diff->setMigrationConfiguration($configuration);
$exec->setMigrationConfiguration($configuration);
$gen->setMigrationConfiguration($configuration);
$migrate->setMigrationConfiguration($configuration);
$status->setMigrationConfiguration($configuration);
$ver->setMigrationConfiguration($configuration);
$cli = ConsoleRunner::createApplication($helperSet, [$diff, $exec, $gen, $migrate, $status, $ver]);
return $cli->run();