protected function execute(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
$locator = $this->getContainer()->get('campaignchain.core.module.locator');
$bundles = $locator->getAvailableBundles();
$selectedBundle = $this->selectBundle($bundles);
$generateOutput = new BufferedOutput();
$application = new Application($this->getContainer()->get('kernel'));
$application->setAutoExit(false);
$application->run(new ArrayInput(['command' => $this->getDoctrineMigrationsCommand(), '--no-interaction' => true]), $generateOutput);
preg_match('/Generated new migration class to "(.*)"/', $generateOutput->fetch(), $matches);
if (count($matches) < 2) {
//error
return;
}
$pathForMigrationFile = $matches[1];
preg_match('/Version.*.php/', $pathForMigrationFile, $fileNames);
if (!count($fileNames)) {
return;
}
$schemaFile = $this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..';
$schemaFile .= DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $selectedBundle->getName();
$schemaFile .= str_replace('/', DIRECTORY_SEPARATOR, $this->getContainer()->getParameter('campaignchain_update.bundle.schema_dir'));
$schemaFile .= DIRECTORY_SEPARATOR . $fileNames[0];
$fs = new Filesystem();
$fs->copy($pathForMigrationFile, $schemaFile);
$fs->remove($pathForMigrationFile);
$this->io->success('Generation finished. You can find the file here:');
$this->io->text($schemaFile);
}