mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
支持配置批量注册根命名空间
This commit is contained in:
@@ -7,6 +7,8 @@ return [
|
|||||||
|
|
||||||
// 应用模式状态
|
// 应用模式状态
|
||||||
'app_status' => '',
|
'app_status' => '',
|
||||||
|
// 注册的根命名空间
|
||||||
|
'root_namespace' => [],
|
||||||
// 扩展配置文件
|
// 扩展配置文件
|
||||||
'extra_config_list' => ['database', 'route'],
|
'extra_config_list' => ['database', 'route'],
|
||||||
// 扩展函数文件
|
// 扩展函数文件
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ class App
|
|||||||
// 获取配置参数
|
// 获取配置参数
|
||||||
$config = Config::get();
|
$config = Config::get();
|
||||||
|
|
||||||
|
// 注册根命名空间
|
||||||
|
if (!empty($config['root_namespace'])) {
|
||||||
|
Loader::addNamespace($config['root_namespace']);
|
||||||
|
}
|
||||||
|
|
||||||
// 加载额外文件
|
// 加载额外文件
|
||||||
if (!empty($config['extra_file_list'])) {
|
if (!empty($config['extra_file_list'])) {
|
||||||
foreach ($config['extra_file_list'] as $file) {
|
foreach ($config['extra_file_list'] as $file) {
|
||||||
|
|||||||
@@ -87,9 +87,13 @@ class Loader
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 注册命名空间
|
// 注册命名空间
|
||||||
public static function addNamespace($namespace, $path)
|
public static function addNamespace($namespace, $path = '')
|
||||||
{
|
{
|
||||||
self::$namespace[$namespace] = $path;
|
if (is_array($namespace)) {
|
||||||
|
self::$namespace = array_merge(self::$namespace, $namespace);
|
||||||
|
} else {
|
||||||
|
self::$namespace[$namespace] = $path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注册自动加载机制
|
// 注册自动加载机制
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ErrorException extends Exception
|
|||||||
* @param integer $line 出错行号
|
* @param integer $line 出错行号
|
||||||
* @param array $context 错误上下文,会包含错误触发处作用域内所有变量的数组
|
* @param array $context 错误上下文,会包含错误触发处作用域内所有变量的数组
|
||||||
*/
|
*/
|
||||||
public function __construct($severity, $message, $file, $line, $context)
|
public function __construct($severity, $message, $file, $line, array $context = [])
|
||||||
{
|
{
|
||||||
$this->severity = $severity;
|
$this->severity = $severity;
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
|
|||||||
Reference in New Issue
Block a user