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;
|
$hasConfig = $this->config->get('module_tgshop_app_name') !== null;
|
||||||
|
|
||||||
if ($hasConfig) {
|
if ($hasConfig) {
|
||||||
|
$this->updateConfigFromDefaults();
|
||||||
$this->config();
|
$this->config();
|
||||||
} else {
|
} else {
|
||||||
$this->init();
|
$this->init();
|
||||||
@@ -235,6 +236,8 @@ class ControllerExtensionModuleTgshop extends Controller
|
|||||||
|
|
||||||
private function getDefaultConfig(): array
|
private function getDefaultConfig(): array
|
||||||
{
|
{
|
||||||
|
$this->load->model('tool/image');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'module_tgshop_status' => 1,
|
'module_tgshop_status' => 1,
|
||||||
'module_tgshop_app_name' => $this->config->get('config_meta_title'),
|
'module_tgshop_app_name' => $this->config->get('config_meta_title'),
|
||||||
@@ -426,4 +429,22 @@ TEXT,
|
|||||||
|
|
||||||
return $map;
|
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