Skip to content

Commit

Permalink
优化getConfig方法
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaobo.sun committed Oct 9, 2016
1 parent 9b39ed0 commit 2d25a57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"homepage": "https://github.com/5ini99/think-addons",
"license": "Apache-2.0",
"minimum-stability": "stable",
"version": "1.0.2",
"authors": [
{
"name": "xiaobo.sun",
Expand Down
26 changes: 11 additions & 15 deletions src/Addons.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,21 @@ final public function getConfig($name = '')
}
$map['name'] = $name;
$map['status'] = 1;
$config = Db::name('Addons')->where($map)->value('config');
if ($config) {
$config = json_decode($config, true);
} else {
if (is_file($this->config_file)) {
$temp_arr = include $this->config_file;
foreach ($temp_arr as $key => $value) {
if ($value['type'] == 'group') {
foreach ($value['options'] as $gkey => $gvalue) {
foreach ($gvalue['options'] as $ikey => $ivalue) {
$config[$ikey] = $ivalue['value'];
}
$config = [];
if (is_file($this->config_file)) {
$temp_arr = include $this->config_file;
foreach ($temp_arr as $key => $value) {
if ($value['type'] == 'group') {
foreach ($value['options'] as $gkey => $gvalue) {
foreach ($gvalue['options'] as $ikey => $ivalue) {
$config[$ikey] = $ivalue['value'];
}
} else {
$config[$key] = $temp_arr[$key]['value'];
}
} else {
$config[$key] = $temp_arr[$key]['value'];
}
unset($temp_arr);
}
unset($temp_arr);
}
$_config[$name] = $config;

Expand Down

0 comments on commit 2d25a57

Please sign in to comment.