feat(admin): correct merge new default settings after initializing app
This commit is contained in:
@@ -66,6 +66,7 @@ class ControllerExtensionModuleTgshop extends Controller
|
||||
$hasConfig = $this->config->get('module_tgshop_app_name') !== null;
|
||||
|
||||
if ($hasConfig) {
|
||||
$this->updateConfigFromDefaults();
|
||||
$this->config();
|
||||
} else {
|
||||
$this->init();
|
||||
@@ -235,6 +236,8 @@ class ControllerExtensionModuleTgshop extends Controller
|
||||
|
||||
private function getDefaultConfig(): array
|
||||
{
|
||||
$this->load->model('tool/image');
|
||||
|
||||
return [
|
||||
'module_tgshop_status' => 1,
|
||||
'module_tgshop_app_name' => $this->config->get('config_meta_title'),
|
||||
@@ -426,4 +429,22 @@ TEXT,
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
private function updateConfigFromDefaults()
|
||||
{
|
||||
$defaults = $this->getDefaultConfig();
|
||||
$settings = $this->model_setting_setting->getSetting('module_tgshop');
|
||||
|
||||
$diff = [];
|
||||
foreach ($defaults as $key => $value) {
|
||||
if (! isset($settings[$key])) {
|
||||
$diff[$key] = $defaults[$key];
|
||||
}
|
||||
}
|
||||
|
||||
if ($diff) {
|
||||
$settings = array_merge($settings, $diff);
|
||||
$this->model_setting_setting->editSetting('module_tgshop', $settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
0
module/oc_telegram_shop/upload/oc_telegram_shop/framework/Contracts/ExceptionHandlerInterface.php
Normal file → Executable file
0
module/oc_telegram_shop/upload/oc_telegram_shop/framework/Contracts/ExceptionHandlerInterface.php
Normal file → Executable file
Reference in New Issue
Block a user