diff --git a/www-api/app/Controllers/BaseController.php b/www-api/app/Controllers/BaseController.php index baa25d09..f1e1bf0d 100644 --- a/www-api/app/Controllers/BaseController.php +++ b/www-api/app/Controllers/BaseController.php @@ -49,7 +49,7 @@ abstract class BaseController extends Controller public $wrenchboard=null; public $micro_service_net1; public $user_server_name =''; - + public $allSettings = []; /** * Constructor. */ @@ -69,6 +69,7 @@ abstract class BaseController extends Controller $this->micro_service_net1 = $this->getSiteConfigurations("system.micro_service_net1"); //"10.10.1 $this->user_server_name = $this->getSiteConfigurations("system.server_name"); // 'https://dev-users.wrenchboard.com'; + $this->getSettings(''); // help create all settings data // $appConfig = config('Cache'); // $appConfig->redis['host'] = $this->getSiteConfigurations("system.cache_host"); // $this->cache_server = cache()->initialize($appConfig); @@ -600,4 +601,24 @@ wrenchboard=# } + protected function getSettings($settingkey, $defaultVal=''){ + $raw_json = file_get_contents('php://input'); + $in = json_decode($raw_json, true); + $out=[]; + $endpoint = "SETTINGS"; + $out = $this->getCache($endpoint); + if (!is_array($out) || count($out)==0 ) { + $local_url = "http://".$this->micro_service_net1.":3037/settings"; + $out = $this->APIcall('GET', $local_url, $in); + if (count($out['result_list']) > 0 ){ // dont cache empty + $this->saveCache($endpoint,$out,55500); + } + } + + if (is_array($out) && count($out['result_list']) > 0 ) { + $this->allSettings = $out['result_list']; + return (isset($out['result_list'][$settingkey])) ? $out['result_list'][$settingkey]: $defaultVal; + } + return $defaultVal; + } } diff --git a/www-api/app/Controllers/WrenchWallet.php b/www-api/app/Controllers/WrenchWallet.php index e6be52b5..6f289756 100644 --- a/www-api/app/Controllers/WrenchWallet.php +++ b/www-api/app/Controllers/WrenchWallet.php @@ -178,25 +178,25 @@ class WrenchWallet extends BaseController return json_encode( $final_out ); } - private function getSettings($settingkey, $defaultVal=''){ - $raw_json = file_get_contents('php://input'); - $in = json_decode($raw_json, true); - $out=[]; - $endpoint = "SETTINGS"; - $out = $this->getCache($endpoint); - if (!is_array($out) || count($out)==0 ) { - $local_url = "http://".$this->micro_service_net1.":3037/settings"; - $out = $this->APIcall('GET', $local_url, $in); - if (count($out['result_list']) > 0 ){ // dont cache empty - $this->saveCache($endpoint,$out,55500); - } - } - - if (is_array($out) && count($out['result_list']) > 0 ) { - return (isset($out['result_list'][$settingkey])) ? $out['result_list'][$settingkey]: $defaultVal; - } - return $defaultVal; - } +// private function getSettings($settingkey, $defaultVal=''){ +// $raw_json = file_get_contents('php://input'); +// $in = json_decode($raw_json, true); +// $out=[]; +// $endpoint = "SETTINGS"; +// $out = $this->getCache($endpoint); +// if (!is_array($out) || count($out)==0 ) { +// $local_url = "http://".$this->micro_service_net1.":3037/settings"; +// $out = $this->APIcall('GET', $local_url, $in); +// if (count($out['result_list']) > 0 ){ // dont cache empty +// $this->saveCache($endpoint,$out,55500); +// } +// } +// +// if (is_array($out) && count($out['result_list']) > 0 ) { +// return (isset($out['result_list'][$settingkey])) ? $out['result_list'][$settingkey]: $defaultVal; +// } +// return $defaultVal; +// } //getKidWallet from parent side public function getKidWallet(){ log_message('critical', "0001");