| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace App\Module\Admin\Providers;
- use App\Module\Admin\Events\AdminActionEvent;
- use App\Module\Admin\Listeners\AdminActionListener;
- use Illuminate\Support\Facades\Event;
- use Illuminate\Support\ServiceProvider;
- /**
- * Admin模块服务提供者
- *
- * 负责注册Admin模块的服务、事件监听器等
- */
- class AdminServiceProvider extends ServiceProvider
- {
- /**
- * 注册服务
- *
- * @return void
- */
- public function register()
- {
- // 注册服务,不需要注册服务
- // $this->registerServices();
- }
- /**
- * 启动服务
- *
- * @return void
- */
- public function boot()
- {
- // 注册事件监听器
- $this->registerEventListeners();
- // 注册命令
- $this->registerCommands();
- // 发布资源,没有可发布的资源
- // $this->publishResources();
- }
- /**
- * 注册服务
- *
- * @return void
- */
- protected function registerServices()
- {
- // 注册 AdminService
- $this->app->singleton('admin.service', function ($app) {
- return new \App\Module\Admin\Services\AdminService();
- });
- // 注册 CacheService
- $this->app->singleton('admin.cache', function ($app) {
- return new \App\Module\Admin\Services\CacheService();
- });
- // 注册 LogService
- $this->app->singleton('admin.log', function ($app) {
- return new \App\Module\Admin\Services\LogService();
- });
- }
- /**
- * 注册事件监听器
- *
- * @return void
- */
- protected function registerEventListeners()
- {
- Event::listen(
- AdminActionEvent::class,
- AdminActionListener::class
- );
- }
- /**
- * 注册命令
- *
- * @return void
- */
- protected function registerCommands()
- {
- if ($this->app->runningInConsole()) {
- // 暂时注释掉不存在的命令类
- // $this->commands([
- // \App\Module\Admin\Commands\AdminCacheCommand::class,
- // \App\Module\Admin\Commands\AdminMaintenanceCommand::class,
- // ]);
- }
- }
- }
|