| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- namespace App\Module\Transfer;
- use App\Module\Transfer\Commands\TransferProcessCommand;
- use App\Module\Transfer\Commands\TransferStatsCommand;
- use App\Module\Transfer\Commands\TransferCallbackCommand;
- use App\Module\Transfer\Commands\TransferCleanCommand;
- use App\Module\Transfer\Commands\InsertTransferAdminMenuCommand;
- use Illuminate\Support\ServiceProvider;
- /**
- * Transfer模块服务提供者
- */
- class TransferServiceProvider extends ServiceProvider
- {
- /**
- * 注册服务
- */
- public function register(): void
- {
- // 注册配置文件
- $this->mergeConfigFrom(
- __DIR__ . '/Config/transfer.php',
- 'transfer'
- );
- // 注册服务绑定
- $this->registerServices();
- }
- /**
- * 启动服务
- */
- public function boot(): void
- {
- // 发布配置文件
- $this->publishes([
- __DIR__ . '/Config/transfer.php' => config_path('transfer.php'),
- ], 'transfer-config');
- // 注册命令
- $this->registerCommands();
- // 注册事件监听器
- $this->registerEventListeners();
- // 注册中间件
- $this->registerMiddleware();
- }
- /**
- * 注册服务绑定
- */
- protected function registerServices(): void
- {
- // 注册Transfer服务
- $this->app->singleton('transfer', function () {
- return new \App\Module\Transfer\Services\TransferService();
- });
- // 注册外部API服务
- $this->app->singleton('transfer.api', function () {
- return new \App\Module\Transfer\Services\ExternalApiService();
- });
- }
- /**
- * 注册命令
- */
- protected function registerCommands(): void
- {
- if ($this->app->runningInConsole()) {
- $this->commands([
- TransferProcessCommand::class,
- TransferStatsCommand::class,
- TransferCallbackCommand::class,
- TransferCleanCommand::class,
- InsertTransferAdminMenuCommand::class,
- ]);
- }
- }
- /**
- * 注册事件监听器
- */
- protected function registerEventListeners(): void
- {
- // Transfer模块使用事件驱动架构
- // 事件监听器将在需要时自动注册
- }
- /**
- * 注册中间件
- */
- protected function registerMiddleware(): void
- {
- // Transfer模块不直接提供外部API
- // 通过OpenAPI模块进行对外开放和集成
- }
- /**
- * 获取提供的服务
- */
- public function provides(): array
- {
- return [
- 'transfer',
- 'transfer.api',
- ];
- }
- }
|