fix(settings): keep local can_edit=0 keys in get_settings when SA omits them
Customer /api/get_settings dropped price_provider because SuperAdmin catalog did not return it. Merge SA values when present; otherwise keep the tenant copy so the app still receives the key. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
namespace App\Services;
|
||||
|
||||
/**
|
||||
* تنظیمات پیشرفته سوپرادمین برای ConfigService.
|
||||
* تنظیمات پیشرفته سوپرادمین برای ConfigService و get_settings.
|
||||
* کش پایدار ندارد؛ فقط یک بار در همان درخواست PHP نگه داشته میشود.
|
||||
*/
|
||||
class SuperAdminProgramSettingsOverlay
|
||||
@@ -36,9 +36,43 @@ class SuperAdminProgramSettingsOverlay
|
||||
private static bool $loaded = false;
|
||||
|
||||
/**
|
||||
* @return array<string, array<string, mixed>>|null null = سوپرادمین در دسترس نبود
|
||||
* همهٔ کلیدهای سوپرادمین (حتی value خالی). null = سوپرادمین در دسترس نبود.
|
||||
*
|
||||
* @return array<string, array<string, mixed>>|null
|
||||
*/
|
||||
public function catalogMap(): ?array
|
||||
{
|
||||
return $this->load();
|
||||
}
|
||||
|
||||
/**
|
||||
* فقط کلیدهایی که سوپرادمین مقدار غیرخالی دارد — برای ConfigService.
|
||||
*
|
||||
* @return array<string, array<string, mixed>>|null
|
||||
*/
|
||||
public function map(): ?array
|
||||
{
|
||||
$full = $this->load();
|
||||
if ($full === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$withValue = [];
|
||||
foreach ($full as $key => $row) {
|
||||
$value = is_array($row) ? ($row['value'] ?? null) : null;
|
||||
if ($value === null || $value === '') {
|
||||
continue;
|
||||
}
|
||||
$withValue[$key] = $row;
|
||||
}
|
||||
|
||||
return $withValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<string, mixed>>|null
|
||||
*/
|
||||
private function load(): ?array
|
||||
{
|
||||
if (self::$loaded) {
|
||||
return self::$memo;
|
||||
@@ -62,11 +96,6 @@ class SuperAdminProgramSettingsOverlay
|
||||
if ($key === '' || in_array($key, self::LOCAL_OWNED_KEYS, true) || in_array($key, self::RUNTIME_KEYS, true)) {
|
||||
continue;
|
||||
}
|
||||
// مقدار خالی قالب سوپرادمین نباید value لوکال tenant را پاک کند
|
||||
$value = $row['value'] ?? null;
|
||||
if ($value === null || $value === '') {
|
||||
continue;
|
||||
}
|
||||
$map[$key] = $row;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user