| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace App\Module\Activity\Providers;
- use Illuminate\Support\ServiceProvider;
- use Illuminate\Support\Facades\Event;
- /**
- * 活动模块服务提供者
- */
- class ActivityServiceProvider extends ServiceProvider
- {
- /**
- * 事件到监听器的映射
- *
- * @var array
- */
- protected $listen = [
- // 活动创建事件
- 'App\Module\Activity\Events\ActivityCreatedEvent' => [
- 'App\Module\Activity\Listeners\ActivityCreatedListener',
- ],
- // 活动状态变更事件
- 'App\Module\Activity\Events\ActivityStatusChangedEvent' => [
- 'App\Module\Activity\Listeners\ActivityStatusChangeListener',
- ],
- // 用户参与活动事件
- 'App\Module\Activity\Events\UserParticipatedEvent' => [
- 'App\Module\Activity\Listeners\UserParticipationListener',
- ],
- // 活动进度更新事件
- 'App\Module\Activity\Events\ActivityProgressUpdatedEvent' => [
- 'App\Module\Activity\Listeners\ActivityProgressListener',
- ],
- // 活动完成事件
- 'App\Module\Activity\Events\ActivityCompletedEvent' => [
- 'App\Module\Activity\Listeners\ActivityCompletedListener',
- ],
- // 活动奖励领取事件
- 'App\Module\Activity\Events\ActivityRewardClaimedEvent' => [
- 'App\Module\Activity\Listeners\RewardDistributionListener',
- ],
- // 签到记录事件
- 'App\Module\Activity\Events\SignInRecordedEvent' => [
- 'App\Module\Activity\Listeners\SignInRecordListener',
- ],
- ];
- /**
- * 注册服务
- */
- public function register()
- {
- }
- /**
- * 启动服务
- */
- public function boot()
- {
- // 注册事件监听器
- foreach ($this->listen as $event => $listeners) {
- foreach ($listeners as $listener) {
- Event::listen($event, $listener);
- }
- }
- }
- }
|