4
4
5
5
/*
6
6
* 配置多继承父类
7
- * @Author: lovefc
8
- * @Date: 2016/8/29 10:51:27
7
+ * @Author: lovefc
8
+ * @Date: 2016/8/29 10:51:27
9
9
* @Last Modified by: lovefc
10
10
* @Last Modified time: 2019-10-12 13:59:55
11
+ * @Last Modified time: 2022-04-19 13:46:23
11
12
*/
12
13
13
14
trait Parents
@@ -96,15 +97,15 @@ public function P_Start()
96
97
* @param [type] $type
97
98
* @return object
98
99
*/
99
- final function ReadConf ($ type )
100
+ final public function ReadConf ($ type )
100
101
{
101
102
if (isset ($ type )) {
102
103
$ this ->P_ConfigType = $ type ;
103
104
}
104
105
if (empty ($ this ->P_ConfigType )) {
105
106
$ this ->P_RegVar = array_keys ($ this ->P_Config );
106
107
} else {
107
- $ this ->P_RegVar = array_keys ($ this ->P_Config [$ this ->P_ConfigType ]);
108
+ $ this ->P_RegVar = isset ( $ this -> P_Config [ $ this -> P_ConfigType ]) ? array_keys ($ this ->P_Config [$ this ->P_ConfigType ]) : [] ;
108
109
}
109
110
// 初始化
110
111
$ this ->P_Start ();
@@ -138,22 +139,8 @@ public function __call($method, $args)
138
139
}
139
140
return $this;
140
141
}
141
- */
142
-
143
- /**
144
- * 获取配置,并关联
145
- *
146
- * @param [type] $file
147
- * @param [type] $file2
148
- * @return array
149
- */
150
- final public static function P_GetConfig ($ file , $ file2 )
151
- {
152
- $ config = self ::P_GetConfigFile ($ file );
153
- $ config2 = self ::P_GetConfigFile ($ file2 );
154
- // 组合配置
155
- return array_replace_recursive ($ config , $ config2 );
156
- }
142
+ */
143
+
157
144
158
145
/**
159
146
* 读取配置目录以及工作目录里的配置文件
@@ -165,12 +152,15 @@ final public static function P_ReadConfigFile($conf)
165
152
{
166
153
$ dir = PATH ['FC_CONFIG ' ];
167
154
$ file = $ dir . '/ ' . $ conf ;
155
+ $ file2 = PATH ['NOW_CONFIG ' ] . '/ ' . $ conf ;
156
+ $ config = $ config2 = [];
168
157
if (is_file ($ file )) {
169
- $ file2 = PATH ['NOW_CONFIG ' ] . '/ ' . $ conf ;
170
- $ config = self ::P_GetConfig ($ file , $ file2 );
171
- return $ config ;
158
+ $ config = self ::P_GetConfigFile ($ file );
172
159
}
173
- return [];
160
+ if (is_file ($ file2 )) {
161
+ $ config2 = self ::P_GetConfigFile ($ file2 );
162
+ }
163
+ return array_replace_recursive ($ config , $ config2 );
174
164
}
175
165
176
166
/**
@@ -242,7 +232,6 @@ final public static function P_Receive($conf)
242
232
$ config = self ::P_GetConfigFile ($ conf , $ ckey );
243
233
$ config2 = self ::P_ImpArray ($ config , $ keys );
244
234
$ re = $ config2 ? $ config2 : $ config ;
245
-
246
235
return $ re ;
247
236
}
248
237
return [];
@@ -263,7 +252,7 @@ final public function P_DefaultArrayConfig()
263
252
264
253
/**
265
254
* 获取到多维数组的值
266
- *
255
+ *
267
256
* @param $config 数组
268
257
* @param $array 键名,多个
269
258
* @return array
0 commit comments