diff --git a/app/Console/Stubs/Modules/providers/event.stub b/app/Console/Stubs/Modules/providers/event.stub index 90a59814f..5284c4ac9 100644 --- a/app/Console/Stubs/Modules/providers/event.stub +++ b/app/Console/Stubs/Modules/providers/event.stub @@ -3,18 +3,28 @@ namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Providers; use Illuminate\Foundation\Support\Providers\EventServiceProvider as Provider; -use $MODULE_NAMESPACE$\$STUDLY_NAME$\Listeners\FinishInstallation; class Event extends Provider { /** - * The event listener mappings for the module. + * Determine if events and listeners should be automatically discovered. * - * @var array + * @return bool */ - protected $listen = [ - \App\Events\Module\Installed::class => [ - FinishInstallation::class, - ], - ]; + public function shouldDiscoverEvents() + { + return true; + } + + /** + * Get the listener directories that should be used to discover events. + * + * @return array + */ + protected function discoverEventsWithin() + { + return [ + __DIR__ . '/../Listeners', + ]; + } } diff --git a/modules/OfflinePayments/Providers/Event.php b/modules/OfflinePayments/Providers/Event.php index a83f4d980..79369acd7 100644 --- a/modules/OfflinePayments/Providers/Event.php +++ b/modules/OfflinePayments/Providers/Event.php @@ -3,26 +3,28 @@ namespace Modules\OfflinePayments\Providers; use Illuminate\Foundation\Support\Providers\EventServiceProvider as Provider; -use Modules\OfflinePayments\Listeners\FinishInstallation; -use Modules\OfflinePayments\Listeners\ShowAsPaymentMethod; -use Modules\OfflinePayments\Listeners\ShowInSettingsPage; class Event extends Provider { /** - * The event listener mappings for the module. + * Determine if events and listeners should be automatically discovered. * - * @var array + * @return bool */ - protected $listen = [ - \App\Events\Module\Installed::class => [ - FinishInstallation::class, - ], - \App\Events\Module\PaymentMethodShowing::class => [ - ShowAsPaymentMethod::class, - ], - \App\Events\Module\SettingShowing::class => [ - ShowInSettingsPage::class, - ], - ]; + public function shouldDiscoverEvents() + { + return true; + } + + /** + * Get the listener directories that should be used to discover events. + * + * @return array + */ + protected function discoverEventsWithin() + { + return [ + __DIR__ . '/../Listeners', + ]; + } } diff --git a/modules/OfflinePayments/Providers/Main.php b/modules/OfflinePayments/Providers/Main.php index a85ddd089..0d6de2ac6 100644 --- a/modules/OfflinePayments/Providers/Main.php +++ b/modules/OfflinePayments/Providers/Main.php @@ -44,7 +44,7 @@ class Main extends Provider */ public function loadTranslations() { - $this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'offline-payments'); + $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'offline-payments'); } /** diff --git a/modules/PaypalStandard/Providers/Event.php b/modules/PaypalStandard/Providers/Event.php index ee4fa3008..cefb2d536 100644 --- a/modules/PaypalStandard/Providers/Event.php +++ b/modules/PaypalStandard/Providers/Event.php @@ -3,18 +3,28 @@ namespace Modules\PaypalStandard\Providers; use Illuminate\Foundation\Support\Providers\EventServiceProvider as Provider; -use Modules\PaypalStandard\Listeners\ShowAsPaymentMethod; class Event extends Provider { /** - * The event listener mappings for the module. + * Determine if events and listeners should be automatically discovered. * - * @var array + * @return bool */ - protected $listen = [ - \App\Events\Module\PaymentMethodShowing::class => [ - ShowAsPaymentMethod::class, - ], - ]; + public function shouldDiscoverEvents() + { + return true; + } + + /** + * Get the listener directories that should be used to discover events. + * + * @return array + */ + protected function discoverEventsWithin() + { + return [ + __DIR__ . '/../Listeners', + ]; + } }