[ FundEventListener::class . '@handleFundChanged', ], FundTransferEvent::class => [ FundEventListener::class . '@handleFundTransfer', ], FundStatusChangedEvent::class => [ FundEventListener::class . '@handleFundStatusChanged', ], LoginSuccessEvent::class => [ LoginSuccessListener::class . '@handle', ], ]; /** * 需要注册的订阅者 * * @var array */ protected $subscribe = [ FundEventListener::class, ]; /** * 注册服务 * * @return void */ public function register(): void { // 注册服务... $this->app->singleton('fund.account.service', function ($app) { return new \App\Module\Fund\Services\AccountService(); }); $this->app->singleton('fund.log.service', function ($app) { return new \App\Module\Fund\Services\LogService(); }); } /** * 启动服务 * * @return void */ public function boot(): void { // 注册事件监听器 $this->registerEvents(); // 注册命令 if ($this->app->runningInConsole()) { $this->commands([ \App\Module\Fund\Commands\CheckUserLogsCommand::class, \App\Module\Fund\Commands\TestLoginAccountCreationCommand::class, ]); } } /** * 注册事件和监听器 * * @return void */ protected function registerEvents(): void { $events = $this->app['events']; foreach ($this->listen as $event => $listeners) { foreach ($listeners as $listener) { $events->listen($event, $listener); } } foreach ($this->subscribe as $subscriber) { $events->subscribe($subscriber); } } }