[ SystemEventListener::class . '@handleConfigChanged', ], ViewConfigChangedEvent::class => [ SystemEventListener::class . '@handleViewConfigChanged', ], SystemLogCreatedEvent::class => [ SystemEventListener::class . '@handleSystemLogCreated', ], ]; /** * 需要注册的订阅者 * * @var array */ protected $subscribe = [ SystemEventListener::class, ]; /** * 注册服务 * * @return void */ public function register(): void { // 注册服务... $this->app->singleton('system.config.service', function ($app) { return new \App\Module\System\Services\ConfigService(); }); $this->app->singleton('system.view.config.service', function ($app) { return new \App\Module\System\Services\ViewConfigService(); }); $this->app->singleton('system.log.service', function ($app) { return new \App\Module\System\Services\LogService(); }); } /** * 启动服务 * * @return void */ public function boot(): void { // 注册事件监听器 $this->registerEvents(); } /** * 注册事件和监听器 * * @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); } } }