From 80ec3b5e1798f2edcfc9c0ba4a3605257c26908d Mon Sep 17 00:00:00 2001 From: Daniel Klabbers Date: Wed, 7 Feb 2018 13:58:31 +0100 Subject: [PATCH] Improved the console configuring event to support any type of console command to be added --- src/Console/Event/Configuring.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Console/Event/Configuring.php b/src/Console/Event/Configuring.php index 778ee8cf3..aace4860a 100644 --- a/src/Console/Event/Configuring.php +++ b/src/Console/Event/Configuring.php @@ -12,6 +12,7 @@ namespace Flarum\Console\Event; use Flarum\Foundation\Application; +use Illuminate\Console\Command; use Symfony\Component\Console\Application as ConsoleApplication; /** @@ -40,4 +41,22 @@ class Configuring $this->app = $app; $this->console = $console; } + + /** + * Add a console command to the flarum binary. + * + * @param Command|string $command + */ + public function addCommand($command) + { + if (is_string($command)) { + $command = $this->app->make($command); + } + + if ($command instanceof Command) { + $command->setLaravel($this->app); + } + + $this->console->add($command); + } }