core/model/modx/rest/modrestcurlclient.class.php

Show: inherited
Table of Contents

Package
modx  
Subpackage
rest  

\modRestArrayToXML

Package: modx\rest

Utility class for array-to-XML transformations.

Methods

methodpublicisAssoc( mixed $array ) : boolean
static

Determine if a variable is an associative array

Parameters
Name Type Description
$array mixed

The variable to check

Returns
Type Description
boolean True if is an array
Details
Static
 
methodpublictoArray( string $xml ) : array
static

Convert an XML document to a multi dimensional array Pass in an XML document (or SimpleXMLElement object) and this recrusively loops through and builds a representative array

Parameters
Name Type Description
$xml string
  • XML document - can optionally be a SimpleXMLElement object
Returns
Type Description
array ARRAY
methodpublictoXML( array $data, string $rootNodeName = 'ResultSet', \SimpleXMLElement $xml = null ) : string
static

The main function for converting to an XML document.

Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.

Parameters
Name Type Description
$data array
$rootNodeName string
  • what you want the root node to be - defaultsto data.
$xml \SimpleXMLElement
  • should only be used recursively
Returns
Type Description
string XML

\modRestCurlClient

Package: modx\rest

Handles REST requests through a cURL-based client

Parent(s)
\modRestClient

Constants

Constant  OPT_PATH = 'path'
inherited

Inherited from: \modRestClient::OPT_PATH
Const
The path of the request  
Inherited_from
\modRestClient::OPT_PATH  
Constant  OPT_PORT = 'port'
inherited

Inherited from: \modRestClient::OPT_PORT
Const
The port of the request  
Inherited_from
\modRestClient::OPT_PORT  
Constant  OPT_RESPONSE_CLASS = 'restResponse.class'
inherited

Inherited from: \modRestClient::OPT_RESPONSE_CLASS
Const
The response class to use when generating the response object  
Inherited_from
\modRestClient::OPT_RESPONSE_CLASS  
Constant  OPT_TIMEOUT = 'timeout'
inherited

Inherited from: \modRestClient::OPT_TIMEOUT
Const
The number of seconds before the request times out  
Inherited_from
\modRestClient::OPT_TIMEOUT  
Constant  OPT_USERAGENT = 'userAgent'
inherited

Inherited from: \modRestClient::OPT_USERAGENT
Const
The user-agent sent in the request  
Inherited_from
\modRestClient::OPT_USERAGENT  
Constant  OPT_USERPWD = 'userpwd'
inherited

Inherited from: \modRestClient::OPT_USERPWD
Const
The user password to send with the request  
Inherited_from
\modRestClient::OPT_USERPWD  
Constant  OPT_AUTHTYPE = 'authtype'
inherited

Inherited from: \modRestClient::OPT_AUTHTYPE
Const
The authentication type for the request  
Inherited_from
\modRestClient::OPT_AUTHTYPE  

Properties

Propertypublicarray  $config= 'array()'
inherited

The configuration array.Inherited from: \modRestClient::$$config
Default valuearray()Details
Type
array
Access
public  
Inherited_from
\modRestClient::$$config  
Propertypublic\modRestClient  $conn= 'null'
inherited

The client connection instance to use.Inherited from: \modRestClient::$$conn
Default valuenullDetails
Type
\modRestClient
Access
public  
Inherited_from
\modRestClient::$$conn  
Propertypublicstring  $host= ''
inherited

The current host to connect to

Inherited from: \modRestClient::$$host
Details
Type
string
Inherited_from
\modRestClient::$$host  
Propertypublic\modX  $modx= 'null'
inherited

A reference to the modX instance.Inherited from: \modRestClient::$$modx
Default valuenullDetails
Type
\modX
Access
public  
Inherited_from
\modRestClient::$$modx  
Propertypublic\modRestResponse  $response= 'null'
inherited

The response object after a request is made.Inherited from: \modRestClient::$$response
Default valuenullDetails
Type
\modRestResponse
Access
public  
Inherited_from
\modRestClient::$$response  
Propertypublicstring  $responseType= ''xml''
inherited

The expected response typeInherited from: \modRestClient::$$responseType
Default value'xml'Details
Type
string
Access
public  
Inherited_from
\modRestClient::$$responseType  

Methods

methodpublic__construct( \modX $modx, array $config = array() ) : \modRestClient

The constructor for the modRestClient class. Assigns a modX instance reference and sets up the basic config array.

Parameters
Name Type Description
$modx \modX

A reference to the modX object

$config array

An array of configuration options

Returns
Type Description
\modRestClient
methodpublicgetConnection( ) : boolean
inherited

Get the connection class for the client. Defaults to cURL, then fsockopen. If neither exists, returns false.

Inherited from: \modRestClient::getConnection()
Returns
Type Description
boolean True if a connection can be made.
Details
Access
public  
methodpublicrequest( string $host, string $path, string $method = 'GET', array $params = array(), array $options = array() ) : \modRestResponse

Extends modRestClient::request to provide cURL specific request handling

Parameters
Name Type Description
$host string

The host of the REST server.

$path string

The path to request to on the REST server.

$method string

The HTTP method to use for the request. May be GET, PUT or POST.

$params array

An array of parameters to send with the request.

$options array

An array of options to pass to the request.

Returns
Type Description
\modRestResponse The response object.
methodpublicsetAuth( resource $ch, array $options = array() ) : boolean

Set up authentication configuration , if specified, to be used with REST request.

Parameters
Name Type Description
$ch resource

The cURL connection resource.

$options array

An array of options

Returns
Type Description
boolean True if authentication was used.
methodpublicsetOptions( resource $ch, array $options = array() ) : void

Set up cURL-specific options

Parameters
Name Type Description
$ch resource

The cURL connection resource

$options array

An array of options

methodpublicsetProxy( resource $ch, array $options = array() ) : boolean

Set up proxy configuration , if specified, to be used with REST request.

Parameters
Name Type Description
$ch resource

The cURL connection resource.

$options array

An array of options

Returns
Type Description
boolean True if the proxy was setup.
methodpublicsetResponseType( string $type ) : void
inherited

Sets the response type

Inherited from: \modRestClient::setResponseType()
Parameters
Name Type Description
$type string

The type to set, either json or xml

methodpublicsetUrl( resource $ch, string $host, string $path, string $method = 'GET', array $params = array(), array $options = array() ) : boolean

Configure and set the URL to use, along with any request parameters.

Parameters
Name Type Description
$ch resource

The cURL connection resource

$host string

The host to send the request to

$path string

The path of the request

$method string

The method of the request (GET/POST)

$params array

An array of request parameters to attach to the URL

$options array

An array of options when setting the URL

Returns
Type Description
boolean Whether or not the URL was set
Details
See
\modRestClient::request  
methodpublicxml2array( \SimpleXMLElement $obj, array $arr ) : boolean
inherited

Translates a SimpleXMLElement object into an array.

Inherited from: \modRestClient::xml2array()
Parameters
Name Type Description
$obj \SimpleXMLElement
$arr array

&$arr The reference array to store the results in.

Returns
Type Description
boolean True if successful.
Details
Access
public  
Documentation was generated by DocBlox 0.18.1.