clean code

This commit is contained in:
CHIEFSOFT\ameye
2024-07-04 21:26:09 -04:00
parent ea0dba9f9d
commit 60ef644862
3 changed files with 43 additions and 36 deletions
@@ -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 );
}
}
+15 -14
View File
@@ -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
+8 -22
View File
@@ -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
}
}