CRM_Utils_REST
in package
This class handles all REST client requests.
Tags
Table of Contents
Properties
- $rest_timeout : int
- Number of seconds we should let a REST process idle
- $ufClass : string
- Cache the actual UF Class
Methods
- ajax() : array<string|int, mixed>
- Run ajax request.
- ajaxJson() : mixed
- This is a wrapper so you can call an api via json (it returns json too) http://example.org/civicrm/api/json?entity=Contact&action=Get"&json={"contact_type":"Individual","email.get.email":{}} to take all the emails from individuals.
- bootAndRun() : string
- buildParamList() : array<string|int, mixed>|mixed|null
- error() : array<string|int, mixed>
- Generates values needed for error messages.
- fatal() : mixed
- Unused function from the dark ages before PHP Exceptions
- handle() : array<string|int, mixed>|int
- isWebServiceRequest() : bool
- Does this request appear to be a web-service request?
- loadCMSBootstrap() : array<string|int, mixed>|null
- loadTemplate() : mixed
- used to load a template "inline", eg. for ajax, without having to build a menu for each template
- output() : string
- ping() : array<string|int, mixed>
- Simple ping function to test for liveness.
- process() : array<string|int, mixed>|int
- processMultiple() : array<string|int, mixed>
- Callback for multiple ajax api calls from CRM.api3()
- run() : string
- simple() : array<string|int, mixed>
- Generates values needed for non-error responses.
Properties
$rest_timeout
Number of seconds we should let a REST process idle
public
static int
$rest_timeout
= 0
$ufClass
Cache the actual UF Class
public
string
$ufClass
Methods
ajax()
Run ajax request.
public
static ajax() : array<string|int, mixed>
Return values
array<string|int, mixed>ajaxJson()
This is a wrapper so you can call an api via json (it returns json too) http://example.org/civicrm/api/json?entity=Contact&action=Get"&json={"contact_type":"Individual","email.get.email":{}} to take all the emails from individuals.
public
static ajaxJson() : mixed
Works for POST & GET (POST recommended).
bootAndRun()
public
bootAndRun() : string
Return values
stringbuildParamList()
public
static & buildParamList() : array<string|int, mixed>|mixed|null
Return values
array<string|int, mixed>|mixed|nullerror()
Generates values needed for error messages.
public
static error([string $message = 'Unknown Error' ]) : array<string|int, mixed>
Parameters
- $message : string = 'Unknown Error'
Return values
array<string|int, mixed>fatal()
Unused function from the dark ages before PHP Exceptions
public
static fatal(PEAR_Error $pearError) : mixed
Parameters
- $pearError : PEAR_Error
handle()
public
static handle() : array<string|int, mixed>|int
Return values
array<string|int, mixed>|intisWebServiceRequest()
Does this request appear to be a web-service request?
public
static isWebServiceRequest() : bool
It is important to distinguish regular browser-page-loads from web-service-requests. Regular page-loads can be CSRF vectors, and we don't web-services to run via CSRF.
Return values
bool —TRUE if the current request appears to either XMLHttpRequest or non-browser-based.
Indicated by either (a) custom headers like X-Request-With
/X-Civi-Auth
or (b) strong-secret-params that could theoretically appear in URL bar but which
cannot be meaningfully forged for CSRF purposes (like ?api_key=SECRET
or ?_authx=SECRET
).
FALSE if the current request looks like a standard browser request. This request may be generated by
<A HREF>, <IFRAME>, <IMG>, Location:
, or similar CSRF vector.
loadCMSBootstrap()
public
loadCMSBootstrap() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —NULL if execution should proceed; array if the response is already known
loadTemplate()
used to load a template "inline", eg. for ajax, without having to build a menu for each template
public
static loadTemplate() : mixed
output()
public
static output(mixed &$result) : string
Parameters
- $result : mixed
Return values
stringping()
Simple ping function to test for liveness.
public
static ping([string $var = NULL ]) : array<string|int, mixed>
Parameters
- $var : string = NULL
-
The string to be echoed.
Return values
array<string|int, mixed>process()
public
static process(mixed &$args, array<string|int, mixed> $params) : array<string|int, mixed>|int
Parameters
- $args : mixed
- $params : array<string|int, mixed>
Return values
array<string|int, mixed>|intprocessMultiple()
Callback for multiple ajax api calls from CRM.api3()
public
static processMultiple() : array<string|int, mixed>
Return values
array<string|int, mixed>run()
public
run() : string
Return values
stringsimple()
Generates values needed for non-error responses.
public
static simple(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>