*/ private array $commands = [ Consume::class, ]; /** * @var array> */ private array $listeners = [ Broadcast::class => [ PublishEvent::class, ] ]; public function register(): void { $this->registerServices(); } public function boot(): void { $this->registerConfigsPublishment(); $this->registerCommands(); $this->registerListeners(); } private function registerServices(): void { $this->app->bind( SerializerInterface::class, config('rabbitmq.message.serializer', Serializer::class) ); $this->app->bind( UnserializerInterface::class, config('rabbitmq.message.unserializer', Unserializer::class) ); $this->app->bind( EventMapperInterface::class, config('rabbitmq.event.mapper', EventMapper::class) ); } private function registerCommands(): void { $this->commands($this->commands); } private function registerListeners(): void { foreach ($this->listeners as $event => $listeners) { foreach ($listeners as $listener) { Event::listen($event, $listener); } } } private function registerConfigsPublishment(): void { $this->publishes( [ $this->configPath('config/rabbitmq.php') => config_path('rabbitmq.php'), ], 'config' ); } private function configPath(string $path): string { return sprintf('%s/../%s', __DIR__, $path); } }