File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed
Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,24 @@ function site_config($key)
4949 return Config::get ($ key );
5050}
5151
52+ function array_deep_merge (array $ a , array $ b )
53+ {
54+ foreach ($ a as $ key => $ val ) {
55+ if (isset ($ b [$ key ])) {
56+ if (gettype ($ a [$ key ]) != gettype ($ b [$ key ])) {
57+ continue ;
58+ }
59+ if (is_array ($ a [$ key ])) {
60+ $ a [$ key ] = array_deep_merge ($ a [$ key ], $ b [$ key ]);
61+ } else {
62+ $ a [$ key ] = $ b [$ key ];
63+ }
64+ }
65+ }
66+
67+ return $ a ;
68+ }
69+
5270\think \Console::addDefaultCommands ([
5371 'tadmin:init ' => \tadmin \command \Init::class,
5472 'tadmin:migrate:run ' => \tadmin \command \Migrate::class,
Original file line number Diff line number Diff line change @@ -66,12 +66,17 @@ protected function loadConfig()
6666 $ configName = pathinfo ($ file , PATHINFO_FILENAME );
6767 $ config = $ this ->app ->config ->pull ($ configName );
6868
69- $ this ->app ->config ->load ($ file , $ configName );
69+ $ config = array_deep_merge (
70+ require_once $ file ,
71+ $ config
72+ );
73+
74+ $ this ->app ->config ->set ($ config , $ configName );
7075
7176 // 重新加载应用中的同名配置,以覆盖此配置
72- if (is_file ($ this ->app ->getConfigPath ().basename ($ file ))) {
73- $ this ->app ->config ->load ($ this ->app ->getConfigPath ().basename ($ file ), $ configName );
74- }
77+ // if (is_file($this->app->getConfigPath().basename($file))) {
78+ // $this->app->config->load($this->app->getConfigPath().basename($file), $configName);
79+ // }
7580 }
7681 }
7782 }
You can’t perform that action at this time.
0 commit comments