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

Show: inherited
Table of Contents

Package
modx  
Subpackage
rest  

\modRestSockClient

Package: modx\rest

The basic REST client for handling REST requests

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
inherited

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

Inherited from: \modRestClient::__construct()
Parameters
Name Type Description
$modx \modX

&$modx A reference to the modX instance.

$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 socket-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.
Details
Todo
Ensure this strips whitespace that prevents this class from working  
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

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.