WiseLoop PHP REST Services 3.3.1
RESTful web service API framework for PHP
wlRestUtils Class Reference

Static Public Member Functions

static getStatusCodeMessage ($statusCode)
static getRequestMethodForAction ($actionName)
static completeArray ($array, $count, $value=null)
static normalizeArray ($data, $forXml=false)
static encodeToArray ($data, $forXml=false)
static arrayToXml ($array, $rootElement=null, $xml=null)
static isAssoc ($array)

Data Fields

const RESPONSE_TYPE_JSON = 'json'
const RESPONSE_TYPE_XML = 'xml'
const RESPONSE_TYPE_PHP = 'php'
const RESPONSE_TYPE_ARR = 'array'
const RESPONSE_TYPE_PLAIN = 'plain'
const ROUTE_CONTROLLER = 'controller'
const ROUTE_VERSION = 'version'
const ROUTE_ACTION = 'action'
const SETTING_ROUTE = 'route'

Detailed Description

WiseLoop RestUtils class definition
This class provides some useful static methods and constants for the whole WiseLoop PHP Rest Services package.

Author:
WiseLoop

Member Function Documentation

static arrayToXml ( array,
rootElement = null,
xml = null 
) [static]

Converts an array to XML.

Parameters:
array$array
string$rootElement
mixed$xml
Returns:
mixed
static completeArray ( array,
count,
value = null 
) [static]

Completes an array with elements having a specified value until it has a certain number of elements.

Parameters:
array$array
int$countthe number of elements
null$valuethe value to be added to array
Returns:
array
static encodeToArray ( data,
forXml = false 
) [static]

Returns the given data as an array.

Parameters:
mixed$data
bool$forXmlif the result will be used to render XML
Returns:
array the normalized array
static getRequestMethodForAction ( actionName) [static]

Returns the accepted request method type for a givem full service controller action name.
Action names methods are following a convention that they must end with the accepted request method. Ex. For personGet, GET is the request method and personGet method is called if in the request URL the action parameter is be set to person and the request is sent using GET.

Parameters:
string$actionNamefull service controller action name including the request method (Get, Post, Put, Delete)
Returns:
string the accepted request method (GET, POST, PUT, DELETE)
static getStatusCodeMessage ( statusCode) [static]

Returns the text representation for the given http status code.

Parameters:
int$statusCodethe http status code
Returns:
string
static isAssoc ( array) [static]

Checks if the given array is associative.

Parameters:
array$array
Returns:
bool
static normalizeArray ( data,
forXml = false 
) [static]

Encodes the given data to an array and normalizes the keys to make sure they are unique.

Parameters:
mixed$data
bool$forXmlif the result will be used to render XML
Returns:
array

Field Documentation

const RESPONSE_TYPE_ARR = 'array'
const RESPONSE_TYPE_JSON = 'json'
const RESPONSE_TYPE_PHP = 'php'
const RESPONSE_TYPE_PLAIN = 'plain'
const RESPONSE_TYPE_XML = 'xml'
const ROUTE_ACTION = 'action'

Hardcoded key for the service controller action name as defined by the default route format in rest-settings.ini file.
The developer should not give a different meaning to this key by overwriting (using) it in another settings file.

const ROUTE_CONTROLLER = 'controller'

Hardcoded key for the service controller name as defined by the default route format in rest-settings.ini file.
The developer should not give a different meaning to this key by overwriting (using) it in another settings file.

const ROUTE_VERSION = 'version'

Hardcoded key for the service controller version as defined by the default route format in rest-settings.ini file.
The developer should not give a different meaning to this key by overwriting (using) it in another settings file.

const SETTING_ROUTE = 'route'

Hardcoded key for specifying the url route format (the default is defined in rest-settings.ini file).
The developer can specify another route format in another settings file (ex. route=apikey/controller/version/action). The new settings file must be registered to the main service using wlRestService::loadSettings method.

 All Data Structures Functions Variables