faultObject)) { $this->generateFaultResponse($this->faultObject); } else { echo $json->encode($input); } } // fn /** * This method calls functions on the implementation class and returns the output or Fault object in case of error to client * * @return unknown */ function serve(){ $GLOBALS['log']->info('Begin: SugarRestJSON->serve'); $json_data = !empty($_REQUEST['rest_data'])? $GLOBALS['RAW_REQUEST']['rest_data']: ''; if(empty($_REQUEST['method']) || !method_exists($this->implementation, $_REQUEST['method'])){ $er = new SoapError(); $er->set_error('invalid_call'); $this->fault($er); }else{ $method = $_REQUEST['method']; $json = getJSONObj(); $data = $json->decode($json_data); if(!is_array($data))$data = array($data); $res = call_user_func_array(array( $this->implementation, $method),$data); $GLOBALS['log']->info('End: SugarRestJSON->serve'); return $res; } // else } // fn /** * This function sends response to client containing error object * * @param SoapError $errorObject - This is an object of type SoapError * @access public */ function fault($errorObject){ $this->faultServer->faultObject = $errorObject; } // fn function generateFaultResponse($errorObject){ $error = $errorObject->number . ': ' . $errorObject->name . '
' . $errorObject->description; $GLOBALS['log']->error($error); $json = getJSONObj(); ob_clean(); echo $json->encode($errorObject); } // fn } // class