You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
866 B
49 lines
866 B
<?php |
|
/** |
|
* |
|
* ConfigHelper.php |
|
* User: ChenLong |
|
* DateTime: 2020/3/9 13:22 |
|
*/ |
|
|
|
|
|
namespace sdModule\makeAdminBasics; |
|
|
|
|
|
class ConfigHelper |
|
{ |
|
/** |
|
* 配置 |
|
* @var array |
|
*/ |
|
private static $config = []; |
|
|
|
/** |
|
* 加载配置 |
|
*/ |
|
private static function loadConfig() |
|
{ |
|
if (!self::$config) { |
|
self::$config = include_once __DIR__ . '/config.php'; |
|
} |
|
} |
|
|
|
/** |
|
* 获取配置 |
|
* @param $key |
|
* @param null $default |
|
* @return mixed|null |
|
*/ |
|
public static function get($key, $default = null) |
|
{ |
|
self::loadConfig(); |
|
$value = self::$config; |
|
foreach (explode('.', $key) as $subKey) { |
|
if (!is_array($value)) break ; |
|
$value = empty($value[$subKey]) ? $default : $value[$subKey]; |
|
} |
|
|
|
return $value; |
|
} |
|
} |
|
|
|
|