Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad7be73

Browse files
committed
feature#8626 [Console] pass command name automatically if required by the application (xabbuh)
This PR was submitted for the 2.2 branch but it was merged into the master branch instead (closes #8626). Discussion ---------- [Console] pass command name automatically if required by the application | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8625 | License | MIT | Doc PR | Commits ------- 50c8050 [Console] pass command name automatically if required by the application
2 parents 426559f + 81aead2 commit ad7be73

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Symfony/Component/Console/Tester/CommandTester.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ public function __construct(Command $command)
5555
*/
5656
public function execute(array $input, array $options = array())
5757
{
58+
// set the command name automatically if the application requires
59+
// this argument and no command name was passed
60+
if (!isset($input['command'])) {
61+
$application = $this->command->getApplication();
62+
if (null !== $application) {
63+
$definition = $application->getDefinition();
64+
if ($definition->hasArgument('command')) {
65+
$input['command'] = $this->command->getName();
66+
}
67+
}
68+
}
69+
5870
$this->input = new ArrayInput($input);
5971
if (isset($options['interactive'])) {
6072
$this->input->setInteractive($options['interactive']);

0 commit comments

Comments
 (0)