Allow DI in console command constructor (#4920)

Allow DI in console command constructor
This commit is contained in:
Marten 2021-03-18 05:59:30 +01:00 committed by GitHub
parent 27c632034a
commit 83c63f93b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -279,17 +279,13 @@ class PluginBase extends ServiceProviderBase
* Registers a new console (artisan) command
*
* @param string $key The command name
* @param string $class The command class
* @param string|\Closure $command The command class or closure
* @return void
*/
public function registerConsoleCommand($key, $class)
public function registerConsoleCommand($key, $command)
{
$key = 'command.'.$key;
$this->app->singleton($key, function ($app) use ($class) {
return new $class;
});
$this->app->singleton($key, $command);
$this->commands($key);
}