Doctrine Loading Devices - Invalid Flag Does Not Work When Working With Symfony Team

Doctrine -no-interactions flag: fixtures: load command does not work in Symfony command. It works, however, through the terminal. Will I call it right?

When I run this from the package:

/**
 * Loads the fixtures
 * @param \Symfony\Component\Console\Output\OutputInterface $oOutput
 * @return \Symfony\Component\Console\Output\OutputInterface
 */
protected function loadFixturesCommand($oOutput) {
    $oOutput->writeln('<fg=white>Attempting to load fixtures</fg=white>');
    $updateCommand = $this->getApplication()->find('doctrine:fixtures:load');

    $updateArguments = array(
        'command' => 'doctrine:fixtures:load',
        '--no-interaction' => true,
    );

    $updateInput = new ArrayInput($updateArguments);
    $updateCommand->run($updateInput, $oOutput);

    try {
        $updateCommand->run($updateInput, $oOutput);
    } catch (ContextErrorException $e) {
        //..
    }
    return $this;
} 

I will be prompted to load fixtures

But by running this:

php app/console doctrine:fixtures:load --no-interaction

Does not prompt.

What am I doing wrong?

+4
source share
2 answers

I have found a solution. Just call:

$input->setInteractive(false);

Same:

protected function loadFixturesCommand($oOutput) {
    $oOutput->writeln('<fg=white>Attempting to load fixtures</fg=white>');
    $updateCommand = $this->getApplication()->find('doctrine:fixtures:load');

    $updateArguments = array(
        'command' => 'doctrine:fixtures:load'
    );

    $updateInput = new ArrayInput($updateArguments);
    $updateInput->setInteractive(false);
    $updateCommand->run($updateInput, $oOutput);

    try {
        $updateCommand->run($updateInput, $oOutput);
    } catch (ContextErrorException $e) {
        //..
    }
    return $this;
}
+13
source

You can use the parameter --appendto suppress the interaction.

i.e. doctrine:fixtures:load --append

+1
source

Source: https://habr.com/ru/post/1542659/


All Articles