Skip to content

Commit 1b64ff9

Browse files
authored
Merge pull request #29478 from carestad/5.5
[5.5] Ensure artisan command context is forwarded to calls
2 parents 85b2a52 + 4a2083b commit 1b64ff9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Illuminate/Console/Command.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,27 @@ public function callSilent($command, array $arguments = [])
223223
*/
224224
protected function createInputFromArguments(array $arguments)
225225
{
226-
return tap(new ArrayInput($arguments), function ($input) {
226+
return tap(new ArrayInput(array_merge($this->context(), $arguments)), function ($input) {
227227
if ($input->hasParameterOption(['--no-interaction'], true)) {
228228
$input->setInteractive(false);
229229
}
230230
});
231231
}
232232

233+
/**
234+
* Get all of the context passed to the command.
235+
*
236+
* @return array
237+
*/
238+
protected function context()
239+
{
240+
$options = array_only($this->option(), ['no-interaction', 'ansi', 'no-ansi', 'quiet', 'verbose']);
241+
242+
return collect($options)->mapWithKeys(function ($value, $key) {
243+
return ["--{$key}" => $value];
244+
})->filter()->all();
245+
}
246+
233247
/**
234248
* Determine if the given argument is present.
235249
*

0 commit comments

Comments
 (0)