Override symfony2 console commands?

后端 未结 4 1929
囚心锁ツ
囚心锁ツ 2020-12-10 04:56

Is it possible to override symfony2 app/console commands? For example, in the FOS UserBundle I\'d like to add a few more fields it asks when it creates a user with its cons

4条回答
  •  北海茫月
    2020-12-10 05:15

    In Symfony (3.3) you can override console commands by following these links. https://symfony.com/doc/current/console/calling_commands.html and the options at https://symfony.com/doc/current/console/input.html

    Code from symfony doc:

    use Symfony\Component\Console\Input\ArrayInput;
    // ...
    
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $command = $this->getApplication()->find('demo:greet');
    
        $arguments = array(
            'command' => 'demo:greet',
            'name'    => 'Fabien',
            '--yell'  => true,
        );
    
        $greetInput = new ArrayInput($arguments);
        $returnCode = $command->run($greetInput, $output);
    
        // ...
    }
    

提交回复
热议问题