Skip to content

Commit

Permalink
Added settings texts sync with database
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey18106 committed Dec 23, 2022
1 parent 17e9e57 commit 94f4c11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/Migration/AppDataCleanupStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function getName(): string {

public function run(IOutput $output) {
$output->startProgress(1);
// $this->cleanupService->dropAppTables();
$this->cleanupService->deleteAppLogs();
$output->advance(1);
$output->finishProgress();
Expand Down
26 changes: 26 additions & 0 deletions lib/Service/UtilsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function __construct(SettingMapper $settingMapper) {
public function checkForSettingsUpdates($app_data) {
$settings = $this->settingMapper->findAll();
if (count($settings) > 0) {
$this->updateSettingsTexts($app_data, $settings);
$this->checkForNewSettings($app_data, $settings);
$this->checkForDeletedSettings($app_data, $settings);
}
Expand Down Expand Up @@ -94,4 +95,29 @@ private function checkForDeletedSettings(array $app_data, array $settings): void
}
}
}

private function updateSettingsTexts(array $app_data, array $settings) {
$newSettingsKeys = array_map(function ($setting) {
return $setting['name'];
}, $app_data['settings']);
foreach ($settings as $setting) {
if (in_array($setting->getName(), $newSettingsKeys)) {
$newSetting = null;
foreach ($app_data['settings'] as $s) {
if ($s['name'] == $setting->getName()) {
$newSetting = $s;
}
}
if (isset($newSetting)) {
if ($setting->getDescription() !== $newSetting['description']) {
$setting->setDescription($newSetting['description']);
}
if ($setting->getDisplayName() !== $newSetting['displayName']) {
$setting->setDisplayName($newSetting['displayName']);
}
$this->settingMapper->update($setting);
}
}
}
}
}

0 comments on commit 94f4c11

Please sign in to comment.