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

Show: inherited
Table of Contents

Package
modx  
Subpackage
rest  

\modRestServer

Package: modx\rest

An extendable class for handling REST requests.

Constants

Constant  OPT_AUTH = 'authenticate'
Constant  OPT_AUTH_GET = 'authenticateGet'
Constant  OPT_AUTH_USER_VAR = 'authUserVar'
Constant  OPT_AUTH_PASS_VAR = 'authPassVar'
Constant  OPT_ENCODING = 'encoding'
Constant  OPT_ERROR_DATA_NODE = 'error_data_node'
Constant  OPT_ERROR_NODE = 'error_node'
Constant  OPT_ERROR_MESSAGE_NODE = 'error_message_node'
Constant  OPT_FORMAT = 'format'
Constant  OPT_PROCESSORS_PATH = 'processors_path'
Constant  OPT_REQUEST_PATH = 'request_path'
Constant  OPT_REQUEST_VAR = 'requestVar'
Constant  OPT_REALM = 'realm'
Constant  OPT_RENDERERS = 'renderers'

Properties

Propertyprotected\$error  $error= 'false'

The current error message
Default valuefalseDetails
Type
\$error
Access
protected  

Methods

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

Parameters
Name Type Description
$modx \modX

A reference to the modX object

$config array

An array of configuration options

methodprivate_err204( string $output = '' ) : string

Sets HTTP 204 response headers

Parameters
Name Type Description
$output string

The outputted response to send

Returns
Type Description
string
methodprivate_err400( string $output = '' ) : string

Sets HTTP 400 response headers

Parameters
Name Type Description
$output string

The outputted response to send

Returns
Type Description
string
methodprivate_err401( ) : string

Sets HTTP 401 response headers

Returns
Type Description
string
methodprivate_err404( array $scriptProperties = array() ) : string

Sets HTTP 404 response headers

Parameters
Name Type Description
$scriptProperties array

An array of properties

Returns
Type Description
string
methodprivate_err405( string $allowed = 'GET, HEAD' ) : string

Sets HTTP 405 response headers

Parameters
Name Type Description
$allowed string

A comma-separated list of allowed protocols

Returns
Type Description
string
methodprivate_err406( string $output = '' ) : string

Sets HTTP 406 response headers

Parameters
Name Type Description
$output string

The outputted response to send

Returns
Type Description
string
methodprivate_err411( string $output = '' ) : string

Sets HTTP 411 response headers

Parameters
Name Type Description
$output string

The outputted response to send

Returns
Type Description
string
methodprivate_err500( string $output = '' ) : string

Sets HTTP 500 response headers

Parameters
Name Type Description
$output string

The outputted response to send

Returns
Type Description
string
methodprotectedarray2xml( array $array, integer $level = 1 ) : string

Converts an array to xml

Parameters
Name Type Description
$array array
$level integer
Returns
Type Description
string
Details
Access
protected  
methodpublicauthenticate( ) : boolean

Handles basic authentication for the server

Returns
Type Description
boolean True if successful.
Details
Todo
Add an optional usergroup check  
methodpubliccomputePath( ) : string

Computes the path for the REST request

Returns
Type Description
string The absolute path to the processor to load
Details
Access
public  
methodpublicdeny( string $message, array $data = array() ) : string

Deny access and send a 401.

Parameters
Name Type Description
$message string
$data array
Returns
Type Description
string
methodpublicencode( array | \xPDOObject $data, string $root = '' ) : string

Encodes the data to the specified format. Defaults to XML.

Parameters
Name Type Description
$data array | \xPDOObject
$root string
Returns
Type Description
string The encoded message
Details
Access
public  
methodpublicerror( string $message = '', array | \xPDOObject $data = array(), string $type = '404' ) : string

Handles error messages

Parameters
Name Type Description
$message string

An error message

$data array | \xPDOObject

Any additional data

$type string

The type of the error message

Returns
Type Description
string
Details
Access
public  
methodpublichandle( ) : string

Handles the REST request and loads the correct processor. Checks for authentication should it be a type not equal to GET if authenticate is set to true, or always if authenticateGet is set to true.

Returns
Type Description
string
Details
Access
public  
methodpublicsuccess( array | \xPDOObject $data, string $root = '' ) : string

Handles success messages

Parameters
Name Type Description
$data array | \xPDOObject

The data to pass and encode

$root string
Returns
Type Description
string The encoded message
Documentation was generated by DocBlox 0.18.1.