From 63a9258fe487ab739bab8eca24850946e4674945 Mon Sep 17 00:00:00 2001 From: Clark Winkelmann Date: Wed, 7 Feb 2018 12:19:08 +0100 Subject: [PATCH] Add console configuration event (#1349) * Add console configuration event * Fix comment formatting --- .../core/src/Console/Event/Configuring.php | 43 +++++++++++++++++++ framework/core/src/Console/Server.php | 5 +++ 2 files changed, 48 insertions(+) create mode 100644 framework/core/src/Console/Event/Configuring.php diff --git a/framework/core/src/Console/Event/Configuring.php b/framework/core/src/Console/Event/Configuring.php new file mode 100644 index 000000000..778ee8cf3 --- /dev/null +++ b/framework/core/src/Console/Event/Configuring.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Console\Event; + +use Flarum\Foundation\Application; +use Symfony\Component\Console\Application as ConsoleApplication; + +/** + * Configure the console application. + * + * This event is fired after the core commands are added to the application. + */ +class Configuring +{ + /** + * @var Application + */ + public $app; + + /** + * @var ConsoleApplication + */ + public $console; + + /** + * @param Application $app + * @param ConsoleApplication $console + */ + public function __construct(Application $app, ConsoleApplication $console) + { + $this->app = $app; + $this->console = $console; + } +} diff --git a/framework/core/src/Console/Server.php b/framework/core/src/Console/Server.php index 36cdea59d..bd1a7d1d6 100644 --- a/framework/core/src/Console/Server.php +++ b/framework/core/src/Console/Server.php @@ -11,6 +11,7 @@ namespace Flarum\Console; +use Flarum\Console\Event\Configuring; use Flarum\Database\Console\GenerateMigrationCommand; use Flarum\Database\Console\MigrateCommand; use Flarum\Foundation\Application; @@ -19,6 +20,7 @@ use Flarum\Foundation\Console\InfoCommand; use Flarum\Foundation\Site; use Flarum\Install\Console\InstallCommand; use Flarum\Install\InstallServiceProvider; +use Illuminate\Contracts\Events\Dispatcher; use Symfony\Component\Console\Application as ConsoleApplication; class Server @@ -73,6 +75,9 @@ class Server )); } + $events = $this->app->make(Dispatcher::class); + $events->fire(new Configuring($this->app, $console)); + return $console; } }