1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Added env option for setting dark mode default

Also allowed config-centralised default user settings for this change
and bought existing user-level view options into that default settings
system to be cleaner in code usage.

For #2081
This commit is contained in:
Dan Brown
2021-02-07 23:12:05 +00:00
parent af032f8993
commit b0f4500c34
11 changed files with 40 additions and 19 deletions

View File

@ -29,9 +29,9 @@ class SettingService
* Gets a setting from the database,
* If not found, Returns default, Which is false by default.
*/
public function get(string $key, $default = false)
public function get(string $key, $default = null)
{
if ($default === false) {
if (is_null($default)) {
$default = config('setting-defaults.' . $key, false);
}
@ -57,8 +57,12 @@ class SettingService
/**
* Get a user-specific setting from the database or cache.
*/
public function getUser(User $user, string $key, $default = false)
public function getUser(User $user, string $key, $default = null)
{
if (is_null($default)) {
$default = config('setting-defaults.user.' . $key, false);
}
if ($user->isDefault()) {
return $this->getFromSession($key, $default);
}
@ -68,7 +72,7 @@ class SettingService
/**
* Get a value for the current logged-in user.
*/
public function getForCurrentUser(string $key, $default = false)
public function getForCurrentUser(string $key, $default = null)
{
return $this->getUser(user(), $key, $default);
}