doctrine/migrations — pull request #122 by keesschepers (2013-06-27 09:55:08+00:00)
Title: Using get-option('no-interaction') makes it unpossible for me to make it un-interactive

I was implementing the doctrine:migrations:migrate command into another command and don't want the migrate command to act interactively. My code was:

getApplication();
$command = $application->find('doctrine:migrations:migrate');

try {
$environment = getenv('MCIS_ENVIRONMENT');
$configurationFile = getcwd() . '/db-config.ini';

if (false === file_exists($configurationFile)) {
throw new \RuntimeException('An INI configuration file is necessary.');
}

$configuration = parse_ini_file($configurationFile, true);

if (false === array_key_exists('atlas-cli', $configuration)) {
throw new \RuntimeException('The [atlas-cli] section is mandatory in the configuration file.');
}

$application->getHelperSet()->set(
new ConnectionHelper(DriverManager::getConnection($configuration['atlas-cli'])),
'db'
);

} catch (\RuntimeException $e) {
$output->writeLn(sprintf('%s', $e->getMessage()));
exit(1);
}

$input = new ArrayInput(array(
null,
'--force',
));
$input->setInteractive(false);
//$input->setOption('no-interaction', true);

$command->run($input, $output);
?>

And symfony/console was still asking me if I really want to run migrations or not. I even tried setOption('no-interaction', true), but then Symfony complains it doesn't reconize the option 'no-interaction'.

After some debugging in the code I found that the $noInteraction variable wasn't looking at the isInteractive method in the input classes but to the no-interaction option it self from the console. I am assuming this works when you run the command from the command line but if you want to integrate it doesn't work.