diff --git a/www-api/app/Controllers/BaseController.php b/www-api/app/Controllers/BaseController.php index 5c685cb1..62959344 100644 --- a/www-api/app/Controllers/BaseController.php +++ b/www-api/app/Controllers/BaseController.php @@ -39,6 +39,10 @@ abstract class BaseController extends Controller protected $helpers = []; private $cache_tag='NONE'; //private $cache_server='10.0.0.32'; + public $current_env=0; + public $primary_image_sever=''; + public $server_tag=''; + public $wrenchboard=null; /** * Constructor. */ @@ -51,6 +55,10 @@ abstract class BaseController extends Controller // E.g.: $this->session = \Config\Services::session(); $this->cache_tag = $this->getSiteConfigurations("system.cache_tag"); + $this->wrenchboard = new \App\Models\BackendModel(); + $this->current_env = $this->getSiteConfigurations("system.live"); + $this->primary_image_sever = $this->getSiteConfigurations("system.primary_image_sever"); + $this->server_tag = $this->getSiteConfigurations("system.server_tag"); //$this->cache_server = $this->getSiteConfigurations("system.cache_host"); // $redis = [ @@ -446,4 +454,16 @@ abstract class BaseController extends Controller array("ty"=>"Completed Jobs", "id"=>"COMPLETED_JOBS", "tag"=>"hist_type_completed_jobs"), ]; } + public function summaryReturnData($in,$out){ + $final_out = ( new \App\Models\ResultFormatter() )->processOutJson($in, $out); + $final_out["environment"] = $this->current_env + 0; + $final_out["session_image_server"] = $this->primary_image_sever; + $final_out["server_tag"] = $this->server_tag; + $final_out["language"] = "en"; + $final_out["ip_loc"] = $this->getIpData(); + $final_out["current_version"] = 20240306; + $final_out["family_types"] = $this->familyTypes(); + $final_out["history_types"] = $this->historyTypes(); + return json_encode( $final_out ); + } } diff --git a/www-api/app/Controllers/WrenchApi.php b/www-api/app/Controllers/WrenchApi.php index 37f8ebef..a96147df 100644 --- a/www-api/app/Controllers/WrenchApi.php +++ b/www-api/app/Controllers/WrenchApi.php @@ -654,8 +654,8 @@ class WrenchApi extends BaseController } if ( $call_backend == true && $in["action"] !='' ){ - $wrenchboard = new \App\Models\BackendModel(); - $ret = $wrenchboard->wrenchboard_api($in, $out); + // $wrenchboard = new \App\Models\BackendModel(); + $ret = $this->wrenchboard->wrenchboard_api($in, $out); $out['internal_return'] = $ret; } else @@ -664,18 +664,19 @@ class WrenchApi extends BaseController } $this->doCacheStep($in, $out); - $final_out = ( new \App\Models\ResultFormatter() )->processOutJson($in, $out); - $final_out["environment"] = $current_env + 0; // force convert to interger = $this->getSiteConfigurations("system.live"); - $final_out["session_image_server"] = $primary_image_sever; // ( $final_out["environment"] > 0 )? 'https://apigate.nebula.g1.wrenchboard.com/en/wrench/api/v1/getmedia/' : "https://apigate.lotus.g1.wrenchboard.com/en/wrench/api/v1/getmedia/"; - //$final_out["session_image_server"] = "https://apigate.lotus.g1.wrenchboard.com/en/wrench/api/v1/getmedia/"; - $final_out["server_tag"] = $server_tag; - $final_out["language"] = "en"; - $final_out["ip_loc"] = $ip_loc; - $final_out["current_version"] = 20240306; - $final_out["family_types"] = $this->familyTypes(); - $final_out["history_types"] = $this->historyTypes(); - //return json_encode( ( new \App\Models\ResultFormatter() )->processOutJson($in, $out)); - return json_encode( $final_out ); +// $final_out = ( new \App\Models\ResultFormatter() )->processOutJson($in, $out); +// $final_out["environment"] = $current_env + 0; // force convert to interger = $this->getSiteConfigurations("system.live"); +// $final_out["session_image_server"] = $primary_image_sever; // ( $final_out["environment"] > 0 )? 'https://apigate.nebula.g1.wrenchboard.com/en/wrench/api/v1/getmedia/' : "https://apigate.lotus.g1.wrenchboard.com/en/wrench/api/v1/getmedia/"; +// //$final_out["session_image_server"] = "https://apigate.lotus.g1.wrenchboard.com/en/wrench/api/v1/getmedia/"; +// $final_out["server_tag"] = $server_tag; +// $final_out["language"] = "en"; +// $final_out["ip_loc"] = $ip_loc; +// $final_out["current_version"] = 20240306; +// $final_out["family_types"] = $this->familyTypes(); +// $final_out["history_types"] = $this->historyTypes(); +// //return json_encode( ( new \App\Models\ResultFormatter() )->processOutJson($in, $out)); + return $this->summaryReturnData($in,$out); //json_encode( $final_out ); + } private function childBanners(): array diff --git a/www-api/app/Controllers/WrenchGeneralData.php b/www-api/app/Controllers/WrenchGeneralData.php index 16765a26..5696e857 100644 --- a/www-api/app/Controllers/WrenchGeneralData.php +++ b/www-api/app/Controllers/WrenchGeneralData.php @@ -4,17 +4,11 @@ namespace App\Controllers; class WrenchGeneralData extends BaseController { - private $current_env=0; - private $primary_image_sever=''; - private $server_tag=''; - private $wrenchboard; + public function __construct() { - $this->wrenchboard = new \App\Models\BackendModel(); - $this->current_env = $this->getSiteConfigurations("system.live"); - $this->primary_image_sever = $this->getSiteConfigurations("system.primary_image_sever"); - $this->server_tag = $this->getSiteConfigurations("system.server_tag"); + } public function signUpCountry(){ @@ -27,19 +21,11 @@ class WrenchGeneralData extends BaseController $out['internal_return'] = $ret; $this->saveCache($endpoint,$out,$timeLine=15000); } - - // $this->doCacheStep($in, $out); - $final_out = ( new \App\Models\ResultFormatter() )->processOutJson($in, $out); - $final_out["environment"] = $this->current_env + 0; - $final_out["session_image_server"] = $this->primary_image_sever; - $final_out["server_tag"] = $this->server_tag; - $final_out["language"] = "en"; - $final_out["ip_loc"] = $this->getIpData(); - $final_out["current_version"] = 20240306; - $final_out["family_types"] = $this->familyTypes(); - $final_out["history_types"] = $this->historyTypes(); - //return json_encode( ( new \App\Models\ResultFormatter() )->processOutJson($in, $out)); - return json_encode( $final_out ); - + return $this->summaryReturnData($in,$out); //json_encode( $final_out ); } + + public function usersPreferences(){ + //preferences + } + } \ No newline at end of file