cache = Services::cache(); $this->set_settings(); } /** * @return void */ public function set_settings(): void { $cache = $this->cache->get('settings'); if ($cache) { $this->settings = decode_array($cache); } else { try { $appconfig = model(Appconfig::class); foreach ($appconfig->get_all()->getResult() as $app_config) { $this->settings[$app_config->key] = $app_config->value; } $this->cache->save('settings', encode_array($this->settings)); } catch (DatabaseException $e) { // Database table doesn't exist yet (migrations haven't run) // Return empty settings to allow migration page to display $this->settings = [ 'language' => 'english', 'language_code' => 'en', 'company' => 'Home' ]; } } } /** * @return void */ public function update_settings(): void { $this->cache->delete('settings'); $this->set_settings(); } }