core/model/modx/modconnectorresponse.class.php
modConnectorResponse
- Package
- modx
\modConnectorResponse
Encapsulates an HTTP response from the MODX manager.
Includes functions to manipluate header data, such as status codes, as well as manipulating the response body.
- Parent(s)
- \modResponse
- Extends
- modResponse
Properties


string
$_directory= ''
The base location of the processors called by the connectors.
- Type
- string
- Access
- private


\modContentType
$contentType= 'null'
null
Details- Type
- \modContentType
- Inherited_from
- \modResponse::$$contentType
Methods


__construct(
\modX $modx
)
:
void
Creates a modConnectorResponse object.
Name | Type | Description |
---|---|---|
$modx | \modX | A reference to the modX instance |


_decodeLiterals(
string $string
)
:
string
Decodes strings encoded by _encodeLiterals to restore JavaScript literals.
Name | Type | Description |
---|---|---|
$string | string | The JSON-encoded string with encoded literals. |
Type | Description |
---|---|
string | The JSON-encoded string with literals restored. |
- Access
- protected


_encodeLiterals(
mixed $value, integer | string $key
)
:
void
Encodes certain JavaScript literal strings for later decoding.
Name | Type | Description |
---|---|---|
$value | mixed | &$value A reference to the value to be encoded if it is identified as a literal. |
$key | integer | string | The array key corresponding to the value. |
- Access
- protected


checkPreview(
)
:
boolean
Checks to see if the preview parameter is set.
Inherited from: \modResponse::checkPreview()Type | Description |
---|---|
boolean |


outputArray(
array $array, mixed $count
=
false
)
:
string
Return arrays of objects (with count) converted to JSON.
The JSON result includes two main elements, total and results. This format is used for list results.
Name | Type | Description |
---|---|---|
$array | array | An array of data objects. |
$count | mixed | The total number of objects. Used for pagination. |
Type | Description |
---|---|
string | The JSON output. |
- Access
- public


outputContent(
array $options
=
array()
)
:
void
Overrides modResponse::outputContent to provide connector-specific processing.
Name | Type | Description |
---|---|---|
$options | array | Various options that can be set. |


sendRedirect(
string $url, array | boolean $options
=
false, string $type
=
'', string $responseCode
=
''
)
:
void | boolean
Sends a redirect to the specified URL using the specified method.
Inherited from: \modResponse::sendRedirect()Valid $type values include: REDIRECT_REFRESH Uses the header refresh method REDIRECT_META Sends a a META HTTP-EQUIV="Refresh" tag to the output REDIRECT_HEADER Uses the header location method
REDIRECT_HEADER is the default.
Name | Type | Description |
---|---|---|
$url | string | The URL to redirect the client browser to. |
$options | array | boolean | An array of options for the redirect OR indicates if redirect attempts should be counted and limited to 3 (latter is deprecated usage; use count_attempts in options array). |
$type | string | The type of redirection to attempt (deprecated, use type in options array). |
$responseCode | string | The type of HTTP response code HEADER to send for the redirect (deprecated, use responseCode in options array) |
Type | Description |
---|---|
void | boolean |


setDirectory(
string $dir
=
''
)
:
void
Set the physical location of the processor directory for the response handler.
This allows for dynamic processor locations.
Name | Type | Description |
---|---|---|
$dir | string | The directory to set as the processors directory. |
- Access
- public


toJSON(
mixed $data
)
:
string
Converts PHP to JSON with JavaScript literals left in-tact.
JSON does not allow JavaScript literals, but this function encodes certain identifiable literals and decodes them back into literals after modX::toJSON() formats the data.
Name | Type | Description |
---|---|---|
$data | mixed | The PHP data to be converted. |
Type | Description |
---|---|
string | The extended JSON-encoded string. |
- Access
- public