Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)"

This reverts commit b8b6774634, reversing
changes made to 82790559de.
This commit is contained in:
Robin Chalas 2017-03-16 17:10:10 +01:00
parent 6b4cfd6a25
commit 5af47c40dc
3 changed files with 5 additions and 45 deletions

View File

@ -859,10 +859,6 @@ class Application
// ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition
}
// don't bind the input again as it would override any input argument/option set from the command event in
// addition to being useless
$command->setInputBound(true);
$event = new ConsoleCommandEvent($command, $input, $output);
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);

View File

@ -42,7 +42,6 @@ class Command
private $ignoreValidationErrors = false;
private $applicationDefinitionMerged = false;
private $applicationDefinitionMergedWithArgs = false;
private $inputBound = false;
private $code;
private $synopsis = array();
private $usages = array();
@ -219,13 +218,11 @@ class Command
$this->mergeApplicationDefinition();
// bind the input against the command specific arguments/options
if (!$this->inputBound) {
try {
$input->bind($this->definition);
} catch (ExceptionInterface $e) {
if (!$this->ignoreValidationErrors) {
throw $e;
}
try {
$input->bind($this->definition);
} catch (ExceptionInterface $e) {
if (!$this->ignoreValidationErrors) {
throw $e;
}
}
@ -681,14 +678,6 @@ class Command
return $output->fetch();
}
/**
* @internal
*/
public function setInputBound($inputBound)
{
$this->inputBound = $inputBound;
}
/**
* Validates a command name.
*

View File

@ -1113,31 +1113,6 @@ class ApplicationTest extends TestCase
$this->assertEquals('some test value', $extraValue);
}
public function testUpdateInputFromConsoleCommandEvent()
{
$dispatcher = $this->getDispatcher();
$dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) {
$event->getInput()->setOption('extra', 'overriden');
});
$application = new Application();
$application->setDispatcher($dispatcher);
$application->setAutoExit(false);
$application
->register('foo')
->addOption('extra', null, InputOption::VALUE_REQUIRED)
->setCode(function (InputInterface $input, OutputInterface $output) {
$output->write('foo.');
})
;
$tester = new ApplicationTester($application);
$tester->run(array('command' => 'foo', '--extra' => 'original'));
$this->assertEquals('overriden', $tester->getInput()->getOption('extra'));
}
public function testTerminalDimensions()
{
$application = new Application();