diff --git a/src/Illuminate/Foundation/Console/EventListCommand.php b/src/Illuminate/Foundation/Console/EventListCommand.php new file mode 100644 index 000000000000..e3d590a4c891 --- /dev/null +++ b/src/Illuminate/Foundation/Console/EventListCommand.php @@ -0,0 +1,53 @@ +table(['Event', 'Listeners'], $this->getEvents()); + } + + /** + * Get all of the events and listeners configured for the application. + * + * @return array + */ + protected function getEvents() + { + $events = []; + + foreach ($this->laravel->getProviders(EventServiceProvider::class) as $provider) { + $providerEvents = array_merge($provider->discoverEvents(), $provider->listens()); + + $events = array_merge_recursive($events, $providerEvents); + } + + return collect($events)->map(function ($value, $key) { + return ['Event' => $key, 'Listeners' => implode("\n", $value)]; + })->values()->toArray(); + } +} diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index 9ea9bb08987f..110d5e89a663 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -19,6 +19,7 @@ use Illuminate\Foundation\Console\OptimizeCommand; use Illuminate\Foundation\Console\RuleMakeCommand; use Illuminate\Foundation\Console\TestMakeCommand; +use Illuminate\Foundation\Console\EventListCommand; use Illuminate\Foundation\Console\EventMakeCommand; use Illuminate\Foundation\Console\ModelMakeCommand; use Illuminate\Foundation\Console\RouteListCommand; @@ -93,6 +94,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'Environment' => 'command.environment', 'EventCache' => 'command.event.cache', 'EventClear' => 'command.event.clear', + 'EventList' => 'command.event.list', 'KeyGenerate' => 'command.key.generate', 'Migrate' => 'command.migrate', 'MigrateFresh' => 'command.migrate.fresh', @@ -430,6 +432,18 @@ protected function registerEventClearCommand() }); } + /** + * Register the command. + * + * @return void + */ + protected function registerEventListCommand() + { + $this->app->singleton('command.event.list', function () { + return new EventListCommand(); + }); + } + /** * Register the command. *