checkConfigCommandAlias() public method

alias magerun command in input from config
public checkConfigCommandAlias ( Symfony\Component\Console\Input\InputInterface $input ) : Symfony\Component\Console\Input\ArgvInput | Symfony\Component\Console\Input\InputInterface
$input Symfony\Component\Console\Input\InputInterface
return Symfony\Component\Console\Input\ArgvInput | Symfony\Component\Console\Input\InputInterface
Example #1
0
 /**
  * @test
  */
 public function configCommandAlias()
 {
     $config = new Config();
     $input = new ArgvInput();
     $actual = $config->checkConfigCommandAlias($input);
     $this->assertInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface', $actual);
     $saved = $_SERVER['argv'];
     $config->setConfig(array('commands' => array('aliases' => array(array('list-help' => 'list --help')))));
     $definition = new InputDefinition();
     $definition->addArgument(new InputArgument('command'));
     $argv = array('/path/to/command', 'list-help');
     $_SERVER['argv'] = $argv;
     $input = new ArgvInput($argv, $definition);
     $this->assertSame('list-help', (string) $input);
     $actual = $config->checkConfigCommandAlias($input);
     $this->assertSame('list-help', $actual->getFirstArgument());
     $this->assertSame('list-help --help', (string) $actual);
     $_SERVER['argv'] = $saved;
     $command = new Command('list');
     $config->registerConfigCommandAlias($command);
     $this->assertSame(array('list-help'), $command->getAliases());
 }
Example #2
0
 /**
  * Runs the current application with possible command aliases
  *
  * @param InputInterface $input An Input instance
  * @param OutputInterface $output An Output instance
  *
  * @return integer 0 if everything went fine, or an error code
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $event = new Application\Console\Event($this, $input, $output);
     $this->dispatcher->dispatch(Events::RUN_BEFORE, $event);
     /**
      * only for compatibility to old versions.
      */
     $event = new ConsoleEvent(new Command('dummy'), $input, $output);
     $this->dispatcher->dispatch('console.run.before', $event);
     $input = $this->config->checkConfigCommandAlias($input);
     if ($output instanceof ConsoleOutput) {
         $this->checkVarDir($output->getErrorOutput());
     }
     return parent::doRun($input, $output);
 }