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
=
''
)
:
stringSets HTTP 204 response headers
| Name | Type | Description |
|---|---|---|
| $output | string | The outputted response to send |
| Type | Description |
|---|---|
| string |

_err400(
string $output
=
''
)
:
stringSets HTTP 400 response headers
| Name | Type | Description |
|---|---|---|
| $output | string | The outputted response to send |
| Type | Description |
|---|---|
| string |

_err404(
array $scriptProperties
=
array()
)
:
stringSets HTTP 404 response headers
| Name | Type | Description |
|---|---|---|
| $scriptProperties | array | An array of properties |
| Type | Description |
|---|---|
| string |

_err405(
string $allowed
=
'GET, HEAD'
)
:
stringSets HTTP 405 response headers
| Name | Type | Description |
|---|---|---|
| $allowed | string | A comma-separated list of allowed protocols |
| Type | Description |
|---|---|
| string |

_err406(
string $output
=
''
)
:
stringSets HTTP 406 response headers
| Name | Type | Description |
|---|---|---|
| $output | string | The outputted response to send |
| Type | Description |
|---|---|
| string |

_err411(
string $output
=
''
)
:
stringSets HTTP 411 response headers
| Name | Type | Description |
|---|---|---|
| $output | string | The outputted response to send |
| Type | Description |
|---|---|
| string |

_err500(
string $output
=
''
)
:
stringSets HTTP 500 response headers
| Name | Type | Description |
|---|---|---|
| $output | string | The outputted response to send |
| Type | Description |
|---|---|
| string |

array2xml(
array $array, integer $level
=
1
)
:
stringConverts an array to xml
| Name | Type | Description |
|---|---|---|
| $array | array | |
| $level | integer |
| Type | Description |
|---|---|
| string |
- Access
- protected

authenticate(
)
:
booleanHandles basic authentication for the server
| Type | Description |
|---|---|
| boolean | True if successful. |
- Todo
- Add an optional usergroup check

computePath(
)
:
stringComputes 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()
)
:
stringDeny access and send a 401.
| Name | Type | Description |
|---|---|---|
| $message | string | |
| $data | array |
| Type | Description |
|---|---|
| string |

encode(
array | \xPDOObject $data, string $root
=
''
)
:
stringEncodes 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'
)
:
stringHandles 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(
)
:
stringHandles 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
=
''
)
:
stringHandles success messages
| Name | Type | Description |
|---|---|---|
| $data | array | \xPDOObject | The data to pass and encode |
| $root | string |
| Type | Description |
|---|---|
| string | The encoded message |