Skip to content

Commit

Permalink
Merge pull request #519 from jmolivas/516-refactor-chain-command-feature
Browse files Browse the repository at this point in the history
516 refactor chain command feature
  • Loading branch information
jmolivas committed Mar 21, 2015
2 parents 711b5f1 + 25d20fe commit fff288c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Command/Helper/ChainCommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@

class ChainCommandHelper extends Helper
{

/** @var $commands array */
private $commands;

/**
* @param $name string
* @param $inputs array
* @param $name string
* @param $inputs array
* @param $interactive boolean
* @param $learning boolean
*/
public function addCommand($name, $inputs = [])
public function addCommand($name, $inputs = [], $interactive = null, $learning = null)
{
array_unshift($inputs, ['command' => $name]);
$this->commands[] = ['name' => $name, 'inputs' => $inputs];
$inputs['command'] = $name;
if (!is_null($learning)) {
$inputs['--learning'] = $learning;
}
$this->commands[] = ['name' => $name, 'inputs' => $inputs, 'interactive' => $interactive];
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/EventSubscriber/CallCommandListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public function callCommands(ConsoleTerminateEvent $event)
$callCommand = $application->find($chainedCommand['name']);

$input = new ArrayInput($chainedCommand['inputs']);
if (!is_null($chainedCommand['interactive'])) {
$input->setInteractive($chainedCommand['interactive']);
}
$callCommand->run($input, $output);
}
}
Expand Down

0 comments on commit fff288c

Please sign in to comment.