20 protected $m_sAction =
"";
25 protected $m_aResponse = [];
30 protected $m_nOutputFormat = FORMAT_JSON;
32 public function __call($sName, $aArguments)
36 'status' =>
'success',
50 $this->m_sAction = filter_input(INPUT_GET, CONTROLLER_PARAMETER_ACTION);
51 if (null != $this->m_sAction)
53 $this->m_sAction = ucfirst($this->m_sAction);
57 $this->m_sAction = CONTROLLER_DEFAULT_ACTION;
59 $this->m_nOutputFormat = filter_input(INPUT_GET, CONTROLLER_PARAMETER_FORMAT);
60 if (null != $this->m_nOutputFormat)
62 $this->m_nOutputFormat = strtolower($this->m_nOutputFormat);
66 $this->m_nOutputFormat = FORMAT_JSON;
78 if (FORMAT_STREAM == $this->m_nOutputFormat)
82 $this->m_aResponse = $this->{
"Action" . $this->m_sAction}();
94 $this->m_nOutputFormat = $nOutputFormat;
110 'action' => $sAction,
111 'status' => $sStatus,
125 if (null == $nOutputFormat)
127 $nOutputFormat = $this->m_nOutputFormat;
129 switch ($nOutputFormat)
132 return $this->m_aResponse;
134 header(
'Content-Type: text/plain');
135 return print_r($this->m_aResponse,
true);
137 return "data: " . json_encode($this->m_aResponse);
139 header(
'Content-Type: text/plain');
140 return var_export($this->m_aResponse,
true);
142 header(
'Content-Type: text/html');
143 return arr_get($this->m_aResponse,
'view',
'');
152 header(
'Content-Type: application/json');
153 return json_encode($this->m_aResponse);
155 return $this->m_aResponse;
SetOutputFormat($nOutputFormat=FORMAT_JSON)
GetStandardResponse($sAction= '', $sStatus=STATUS_SUCCESS, $aData=[], $sView= '')
GetOutput($nOutputFormat=null)