DEV: Add plugin hook for transforming site setting defaults (#20941)

This commit is contained in:
David Taylor
2023-04-05 12:28:16 +01:00
committed by GitHub
parent 81566949f5
commit df849e51b7
3 changed files with 65 additions and 9 deletions

View File

@@ -31,18 +31,18 @@ class SiteSettings::DefaultsProvider
end
def all(locale = nil)
if locale
@defaults[DEFAULT_LOCALE.to_sym].merge(@defaults[locale.to_sym] || {})
else
@defaults[DEFAULT_LOCALE.to_sym].dup
end
result =
if locale
@defaults[DEFAULT_LOCALE.to_sym].merge(@defaults[locale.to_sym] || {})
else
@defaults[DEFAULT_LOCALE.to_sym].dup
end
DiscoursePluginRegistry.apply_modifier(:site_setting_defaults, result)
end
def get(name, locale = DEFAULT_LOCALE)
value = @defaults.dig(locale.to_sym, name.to_sym)
return value unless value.nil?
@defaults.dig(DEFAULT_LOCALE.to_sym, name.to_sym)
all(locale)[name.to_sym]
end
alias [] get