core/model/modx/modconnectorresponse.class.php

Show: inherited
Table of Contents

modConnectorResponse

Package
modx  

\modConnectorResponse

Package: modx

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

Propertyprotectedstring  $_directory= ''

The base location of the processors called by the connectors.

Details
Type
string
Access
private  
Propertypublicstring  $body= 'null'
inherited

The body of this response

Inherited from: \modResponse::$$body
Default valuenullDetails
Type
string
Inherited_from
\modResponse::$$body  
Propertypublic\modContentType  $contentType= 'null'
inherited

The current content type on the resource

Inherited from: \modResponse::$$contentType
Default valuenullDetails
Type
\modContentType
Inherited_from
\modResponse::$$contentType  
Propertypublicstring  $header= 'null'
inherited

The HTTP header for this Response

Inherited from: \modResponse::$$header
Default valuenullDetails
Type
string
Inherited_from
\modResponse::$$header  
Propertypublic\modX  $modx= 'null'
inherited

A reference to the modX instance

Inherited from: \modResponse::$$modx
Default valuenullDetails
Type
\modX
Inherited_from
\modResponse::$$modx  

Methods

methodpublic__construct( \modX $modx ) : void

Creates a modConnectorResponse object.

Parameters
Name Type Description
$modx \modX

A reference to the modX instance

methodprotected_decodeLiterals( string $string ) : string

Decodes strings encoded by _encodeLiterals to restore JavaScript literals.

Parameters
Name Type Description
$string string

The JSON-encoded string with encoded literals.

Returns
Type Description
string The JSON-encoded string with literals restored.
Details
Access
protected  
methodprotected_encodeLiterals( mixed $value, integer | string $key ) : void

Encodes certain JavaScript literal strings for later decoding.

Parameters
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.

Details
Access
protected  
methodpubliccheckPreview( ) : boolean
inherited

Checks to see if the preview parameter is set.

Inherited from: \modResponse::checkPreview()
Returns
Type Description
boolean
methodpublicoutputArray( 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.

Parameters
Name Type Description
$array array

An array of data objects.

$count mixed

The total number of objects. Used for pagination.

Returns
Type Description
string The JSON output.
Details
Access
public  
methodpublicoutputContent( array $options = array() ) : void

Overrides modResponse::outputContent to provide connector-specific processing.

Parameters
Name Type Description
$options array

Various options that can be set.

methodpublicsendRedirect( string $url, array | boolean $options = false, string $type = '', string $responseCode = '' ) : void | boolean
inherited

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.

Parameters
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)

Returns
Type Description
void | boolean
methodpublicsetDirectory( string $dir = '' ) : void

Set the physical location of the processor directory for the response handler.

This allows for dynamic processor locations.

Parameters
Name Type Description
$dir string

The directory to set as the processors directory.

Details
Access
public  
methodpublictoJSON( 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.

Parameters
Name Type Description
$data mixed

The PHP data to be converted.

Returns
Type Description
string The extended JSON-encoded string.
Details
Access
public  
Documentation was generated by DocBlox 0.18.1.