mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 13:38:20 +01:00
Work on config caching
This commit is contained in:
parent
7a3c231f68
commit
77f455651d
@ -14,6 +14,8 @@ namespace CachetHQ\Cachet\Foundation\Providers;
|
||||
use CachetHQ\Cachet\Config\Repository;
|
||||
use CachetHQ\Cachet\Models\Setting as SettingModel;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
@ -32,6 +34,20 @@ class ConfigServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if ($this->app->configurationIsCached()) {
|
||||
if ($this->app->environment() === 'production') {
|
||||
$this->app->terminating(function () {
|
||||
if ($this->app->setting->stale()) {
|
||||
$this->app->make(Kernel::class)->call('config:cache');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$this->app->make(Kernel::class)->call('config:clear');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Get the default settings.
|
||||
$defaultSettings = $this->app->config->get('setting');
|
||||
@ -72,6 +88,12 @@ class ConfigServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
$this->app->config->set('cors.paths.api/v1/*.allowedOrigins', $allowedOrigins);
|
||||
|
||||
if ($this->app->environment() === 'production') {
|
||||
$this->app->terminating(function () {
|
||||
$this->app->make(Kernel::class)->call('config:cache');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user