init
- 框架初始化 - 安装插件 - 修复PHP8.4报错
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Service;
|
||||
|
||||
use Yansongda\Pay\Contract\ConfigInterface;
|
||||
use Yansongda\Pay\Contract\ServiceProviderInterface;
|
||||
use Yansongda\Pay\Exception\ContainerException;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Supports\Config;
|
||||
|
||||
class ConfigServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
private array $config = [
|
||||
'logger' => [
|
||||
'enable' => false,
|
||||
'file' => null,
|
||||
'identify' => 'yansongda.pay',
|
||||
'level' => 'debug',
|
||||
'type' => 'daily',
|
||||
'max_files' => 30,
|
||||
],
|
||||
'http' => [
|
||||
'timeout' => 5.0,
|
||||
'connect_timeout' => 3.0,
|
||||
'headers' => [
|
||||
'User-Agent' => 'yansongda/pay-v3',
|
||||
],
|
||||
],
|
||||
'mode' => Pay::MODE_NORMAL,
|
||||
];
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
*
|
||||
* @throws ContainerException
|
||||
*/
|
||||
public function register($data = null): void
|
||||
{
|
||||
$config = new Config(array_replace_recursive($this->config, $data ?? []));
|
||||
|
||||
Pay::set(ConfigInterface::class, $config);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user