From 2f4654d02ac57793d00ddda161793118bf5ffe3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=99=E5=AD=A6=E6=9D=B0?= Date: Tue, 29 Jan 2019 14:35:24 +0800 Subject: [PATCH] config --- src/config.php => config/wx.php | 4 +- .../ServerProvider/WechatServiceProvider.php | 40 ++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) rename src/config.php => config/wx.php (73%) diff --git a/src/config.php b/config/wx.php similarity index 73% rename from src/config.php rename to config/wx.php index ae0cb6a..0ec8b19 100644 --- a/src/config.php +++ b/config/wx.php @@ -5,10 +5,10 @@ return [ */ 'work' => [ //企业ID - 'corp_id' => '', + 'corp_id' => env('WECHAT_WORK_CORP_ID'), //企业内各个应用的 secrets 'secrets' => [ - 'auth' => '', + 'miniprogram' => env('WECHAT_WORK_SECRET_MINIPROGRAM'), 'contact' => env('WECHAT_WORK_SECRET_CONTACT'), 'external_contact' => env('WECHAT_WORK_SECRET_EXTERNAL_CONTACT'), ], diff --git a/src/Wechat/ServerProvider/WechatServiceProvider.php b/src/Wechat/ServerProvider/WechatServiceProvider.php index a814366..6e50a7d 100644 --- a/src/Wechat/ServerProvider/WechatServiceProvider.php +++ b/src/Wechat/ServerProvider/WechatServiceProvider.php @@ -1 +1,39 @@ -app instanceof LaravelApplication && $this->app->runningInConsole()) { + $this->publishes([$source => config_path('wx.php')], 'wx'); + } elseif ($this->app instanceof LumenApplication) { + $this->app->configure('wx'); + } + + $this->mergeConfigFrom($source, 'rpc'); + } + + public function register() + { + $config = config['wx']; + + if (isset($config['work'])) { + + foreach ($config['work']['secrets'] as $key => $item) { + $this->app->singleton('wx.work.' . $key, function () { + return new ucwords($key); + }); + } + + } + + + } +} \ No newline at end of file