-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace WeWork; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class WeWorkServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Indicates if loading of the provider is deferred. | ||
* | ||
* @var bool | ||
*/ | ||
protected $defer = true; | ||
|
||
/** | ||
* Bootstrap services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->publishes( | ||
[ | ||
__DIR__.'/config.php' => config_path('wework.php'), | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Register services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->singleton( | ||
'wework', | ||
function ($app, $parameters) { | ||
$wework = array_merge($app['config']['wework'], $parameters); | ||
|
||
$config = array_merge( | ||
$wework['agents'][$wework['default']], | ||
[ | ||
'corp_id' => $wework['corp_id'], | ||
'logging' => [ | ||
'path' => $wework['log']['file'], | ||
'level' => $wework['log']['level'], | ||
], | ||
'cache' => [ | ||
'path' => $app['config']['cache.stores.file.path'], | ||
], | ||
] | ||
); | ||
|
||
return new App($config); | ||
} | ||
); | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return ['wework']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
return [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| 企业ID | ||
|-------------------------------------------------------------------------- | ||
| | ||
| 每个企业都拥有唯一的corpid,获取此信息可在管理后台“我的企业”-“企业信息”下查看“企业ID”(需要有管理员权限)。 | ||
| | ||
*/ | ||
|
||
'corp_id' => 'xxxxxxxxxxxxxxxxx', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| 默认应用 | ||
|-------------------------------------------------------------------------- | ||
| | ||
| 定义默认使用的应用。 | ||
| | ||
*/ | ||
|
||
'default' => 'contacts', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| 应用列表 | ||
|-------------------------------------------------------------------------- | ||
| | ||
| 定义应用列表,如果某个应用的某些配置用不到或者不存在,可以不定义。 | ||
| | ||
*/ | ||
|
||
'agents' => [ | ||
'contacts' => [ | ||
'agent_id' => 0, | ||
'secret' => 'xxxxxxxxxxxxxxxxx', | ||
'token' => 'xxxxxxxxxxxxxxxxx', | ||
'aes_key' => 'xxxxxxxxxxxxxxxxx', | ||
], | ||
|
||
//... | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| 日志 | ||
|-------------------------------------------------------------------------- | ||
| | ||
| 定义日志级别和存储位置。 | ||
| | ||
*/ | ||
|
||
'log' => [ | ||
'level' => env('WEWORK_LOG_LEVEL', 'debug'), | ||
'file' => storage_path('logs/wework.log'), | ||
], | ||
]; |