core/model/modx/rest/modrestserver.class.php
- Package
- modx
- Subpackage
- rest
\modRestServer
An extendable class for handling REST requests.
Constants
Properties
Methods
__construct(
\modX $modx, array $config
=
array()
)
:
void
Name | Type | Description |
---|---|---|
$modx | \modX | A reference to the modX object |
$config | array | An array of configuration options |
_err204(
string $output
=
''
)
:
string
Sets HTTP 204 response headers
Name | Type | Description |
---|---|---|
$output | string | The outputted response to send |
Type | Description |
---|---|
string |
_err400(
string $output
=
''
)
:
string
Sets HTTP 400 response headers
Name | Type | Description |
---|---|---|
$output | string | The outputted response to send |
Type | Description |
---|---|
string |
_err404(
array $scriptProperties
=
array()
)
:
string
Sets HTTP 404 response headers
Name | Type | Description |
---|---|---|
$scriptProperties | array | An array of properties |
Type | Description |
---|---|
string |
_err405(
string $allowed
=
'GET, HEAD'
)
:
string
Sets HTTP 405 response headers
Name | Type | Description |
---|---|---|
$allowed | string | A comma-separated list of allowed protocols |
Type | Description |
---|---|
string |
_err406(
string $output
=
''
)
:
string
Sets HTTP 406 response headers
Name | Type | Description |
---|---|---|
$output | string | The outputted response to send |
Type | Description |
---|---|
string |
_err411(
string $output
=
''
)
:
string
Sets HTTP 411 response headers
Name | Type | Description |
---|---|---|
$output | string | The outputted response to send |
Type | Description |
---|---|
string |
_err500(
string $output
=
''
)
:
string
Sets HTTP 500 response headers
Name | Type | Description |
---|---|---|
$output | string | The outputted response to send |
Type | Description |
---|---|
string |
array2xml(
array $array, integer $level
=
1
)
:
string
Converts an array to xml
Name | Type | Description |
---|---|---|
$array | array | |
$level | integer |
Type | Description |
---|---|
string |
- Access
- protected
authenticate(
)
:
boolean
Handles basic authentication for the server
Type | Description |
---|---|
boolean | True if successful. |
- Todo
- Add an optional usergroup check
computePath(
)
:
string
Computes the path for the REST request
Type | Description |
---|---|
string | The absolute path to the processor to load |
- Access
- public
deny(
string $message, array $data
=
array()
)
:
string
Deny access and send a 401.
Name | Type | Description |
---|---|---|
$message | string | |
$data | array |
Type | Description |
---|---|
string |
encode(
array | \xPDOObject $data, string $root
=
''
)
:
string
Encodes the data to the specified format. Defaults to XML.
Name | Type | Description |
---|---|---|
$data | array | \xPDOObject | |
$root | string |
Type | Description |
---|---|
string | The encoded message |
- Access
- public
error(
string $message
=
'', array | \xPDOObject $data
=
array(), string $type
=
'404'
)
:
string
Handles error messages
Name | Type | Description |
---|---|---|
$message | string | An error message |
$data | array | \xPDOObject | Any additional data |
$type | string | The type of the error message |
Type | Description |
---|---|
string |
- Access
- public
handle(
)
:
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.
Type | Description |
---|---|
string |
- Access
- public
success(
array | \xPDOObject $data, string $root
=
''
)
:
string
Handles success messages
Name | Type | Description |
---|---|---|
$data | array | \xPDOObject | The data to pass and encode |
$root | string |
Type | Description |
---|---|
string | The encoded message |