0
私は初めてSymfonyでカスタマイズされたコマンドを作成しようとしています。 このコマンドは、3つのコマンドを一度に実行する必要があります。symfonyのカスタマイズされたコマンドは、最初の実行後に停止します
これは、反復の開始時に問題が発生
class DoctrineFullFixturesLoadCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('doctrine:full-fixtures:load')
->setDescription('...')
->addArgument('argument', InputArgument::OPTIONAL, 'Argument description')
->addOption('option', null, InputOption::VALUE_NONE, 'Option description')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$argument = $input->getArgument('argument');
if ($input->getOption('option')) {
// ...
}
$arrCommands = [
[
'command' => 'doctrine:database:drop',
'--force' => true
], [
'command' => 'doctrine:database:create'
], [
'command' => 'doctrine:schema:update',
'--force' => true,
'--complete' => true
]
];
foreach ($arrCommands as $arrInput) {
$this->getApplication()->run(
new ArrayInput($arrInput),
$output
);
}
$output->writeln('Command result.');
}
}
私のコマンドクラスです。 実際には3行ではなく、行の最初のコマンドだけが実行されます。 何らかの理由で最初のコマンドを実行した後に反復が停止するようですが、実際には最後のメソッド$output->writeln
は全く呼び出されません。