Skip to content

Commit fa80516

Browse files
committed
Fix settings config
1 parent 81a204e commit fa80516

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

‎ProcessMaker/Providers/ProcessMakerServiceProvider.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function boot(): void
5959
// Track the start time for service providers boot
6060
self::$bootStart = microtime(true);
6161

62+
config()->applicationBooted();
63+
6264
$this->app->singleton(Menu::class, function ($app) {
6365
return new MenuManager();
6466
});
@@ -207,9 +209,7 @@ public function register(): void
207209
});
208210

209211
$this->app->extend('config', function ($originalConfig) {
210-
$config = new SettingsConfigRepository($originalConfig->all());
211-
212-
return $config;
212+
return new SettingsConfigRepository($originalConfig->all());
213213
});
214214
}
215215

‎ProcessMaker/Repositories/SettingsConfigRepository.php‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
class SettingsConfigRepository extends Repository
1010
{
11+
// private bool $hasDatabaseConnection = false;
12+
13+
private bool $applicationBooted = false;
14+
1115
/**
1216
* Determine if the given configuration value exists.
1317
*
@@ -20,7 +24,7 @@ public function has($key)
2024
return true;
2125
}
2226

23-
return Setting::byKey($key) ? true : false;
27+
return $this->getFromSettings($key) ? true : false;
2428
}
2529

2630
/**
@@ -40,7 +44,7 @@ public function get($key, $default = null)
4044
return Arr::get($this->items, $key);
4145
}
4246

43-
$setting = Setting::byKey($key);
47+
$setting = $this->getFromSettings($key);
4448
if ($setting) {
4549
return $setting->config;
4650
}
@@ -64,7 +68,7 @@ public function getMany($keys)
6468

6569
if (Arr::has($this->items, $key)) {
6670
$config[$key] = Arr::get($this->items, $key);
67-
} elseif ($setting = Setting::byKey($key)) {
71+
} elseif ($setting = $this->getFromSettings($key)) {
6872
$config[$key] = $setting->config;
6973
} else {
7074
$config[$key] = $default;
@@ -73,4 +77,20 @@ public function getMany($keys)
7377

7478
return $config;
7579
}
80+
81+
private function getFromSettings($key)
82+
{
83+
if (!$this->applicationBooted()) {
84+
\Log::info("Attempting to get setting '$key' before application booted");
85+
86+
return null;
87+
}
88+
89+
return Setting::byKey($key);
90+
}
91+
92+
public function applicationBooted()
93+
{
94+
return $this->applicationBooted = true;
95+
}
7696
}

‎resources/views/shared/users/sidebar.blade.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
</h5>
102102
<div class="form-group">
103103
<div class="custom-control custom-switch">
104-
{!! Form::checkbox('email_task_notification', 1, false, ['id' => 'email_task_notification', 'class' => 'custom-control-input', 'v-model' => 'formData.email_task_notification']) !!}
104+
{{ html()->checkbox('email_task_notification', 1, false)->id('email_task_notification')->class('custom-control-input')->attribute('v-model', 'formData.email_task_notification') }}
105105
<label class="custom-control-label" for="email_task_notification">{{__('Forward notifications to my email address')}}</label>
106106
</div>
107107
</div>

0 commit comments

Comments
 (0)