public function ajaxReturn($code, $msg = '', $data = array()) { $this->view->disable(); $pack = is_array($code) ? $code : data_pack($code, $msg, $data); echo json_encode($pack, JSON_UNESCAPED_UNICODE); exit(0); }
public function checkEnNameUnique($data) { $userModel = $this->getModel(); $result = $userModel->getUserByEnName($data); if (false === $result) { return data_pack(get_code('FIND_DATA_FAIL'), get_lang('OPERATION_FAIL')); } if ($result) { return data_pack(get_code('DATA_REPEATE'), get_lang('DATA_REPEATE', $data['en_name'])); } return data_pack(get_code('SUCC')); }
public function run($name, $args) { $lastSeparator = strrpos($name, '_'); $rpcArgs = array('service' => substr($name, 0, $lastSeparator), 'method' => substr($name, $lastSeparator + 1), 'params' => $args); try { LoggerUtil::info('RPC CALL: ' . json_encode($rpcArgs, JSON_UNESCAPED_UNICODE)); $serviceName = $this->getServiceName($rpcArgs['service'], false); $service = new $serviceName(); $methodName = $rpcArgs['method']; if (!method_exists($service, $methodName)) { throw new \Exception(get_lang('METHOD_NOT_FOUND', $methodName)); } $result = call_user_func_array(array($service, $methodName), $rpcArgs['params']); LoggerUtil::info('RPC SUCC: ' . json_encode($result, JSON_UNESCAPED_UNICODE)); return $result; } catch (\Exception $e) { LoggerUtil::error('RPC FAIL: ' . $e->getMessage()); return data_pack(get_code('REMOTE_RPC_FAIL'), $e->getMessage()); } }
public function afterIndex() { return data_pack(get_code('SUCC'), null, $this->data['origin']); }