model/modx/modprocessor.class.php
- package
- modx
- Classes
- modProcessor
- modProcessorResponse
- modProcessorResponseError
Description
modProcessor
\modProcessor
- package
- modx
- Properties
- $modx
- $path
- $properties
- Methods
- __construct
- _decodeLiterals
- _encodeLiterals
- outputArray
- processEventResponse
- run
- setPath
- setProperties
- toJSON
Description
Abstracts a MODX processor
{@inheritdoc}
Properties
$modx
$modx = 'null'
Details
- visibility
- public
- default
- null
- final
- false
- static
- false
$path
$path = ''
Details
- visibility
- public
- default
- final
- false
- static
- false
$properties
$properties = 'array'
Details
- visibility
- public
- default
- array
- final
- false
- static
- false
Methods
__construct
__construct(
$modx, $config
=
array
)
:
Creates a modProcessor object.
{@inheritdoc}
Arguments
- $modx
- $config
Details
- visibility
- public
- final
- false
- static
- false
_decodeLiterals
_decodeLiterals(
string $string
)
:
string
Decodes strings encoded by _encodeLiterals to restore JavaScript literals.
Arguments
- $string
- string
The JSON-encoded string with encoded literals.
Output
- string
- The JSON-encoded string with literals restored.
Details
- visibility
- protected
- final
- false
- static
- false
- access
- protected
_encodeLiterals
_encodeLiterals(
mixed $value, integer|string $key
)
:
Encodes certain JavaScript literal strings for later decoding.
Arguments
- $value
- mixed
&$value A reference to the value to be encoded if it is identified as a literal. - $key
- integerstring
The array key corresponding to the value.
Details
- visibility
- protected
- final
- false
- static
- false
- access
- protected
outputArray
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.
Arguments
- $array
- array
An array of data objects. - $count
- mixed
The total number of objects. Used for pagination.
Output
- string
- The JSON output.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
processEventResponse
processEventResponse(
\array/string $response, string $separator
=
\n
)
:
string
Processes a response from a Plugin Event invocation
Arguments
- $response
- \array/string
The response generated by the invokeEvent call - $separator
- string
Output
- string
- The processed response.
Details
- visibility
- public
- final
- false
- static
- false
run
run(
)
:
Details
- visibility
- public
- final
- false
- static
- false
setPath
setPath(
$path
)
:
Arguments
- $path
Details
- visibility
- public
- final
- false
- static
- false
setProperties
setProperties(
$properties
)
:
Arguments
- $properties
Details
- visibility
- public
- final
- false
- static
- false
toJSON
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.
Arguments
- $data
- mixed
The PHP data to be converted.
Output
- string
- The extended JSON-encoded string.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
\modProcessorResponse
- package
- modx
- Constants
- ERROR_BOTH
- ERROR_FIELD
- ERROR_GENERAL
- ERROR_TYPE
- Properties
- $error_type
- $errors
- $modx
- $response
- Methods
- __construct
- getAllErrors
- getErrorType
- getFieldErrors
- getMessage
- getObject
- getResponse
- hasFieldErrors
- hasMessage
- hasObject
- isError
Description
Response class for Processor executions
Constants
ERROR_GENERAL
ERROR_GENERAL = 'error_general'
When there is only a general error
Details
- value
- error_general
ERROR_FIELD
ERROR_FIELD = 'error_field'
When there are only field-specific errors
Details
- value
- error_field
ERROR_BOTH
ERROR_BOTH = 'error_both'
When there is both field-specific and general errors
Details
- value
- error_both
ERROR_TYPE
ERROR_TYPE = 'error_type'
The field for the error type
Details
- value
- error_type
Properties
$error_type
string $error_type = ''
Details
- string
The error type for this response - visibility
- public
- default
- final
- false
- static
- false
$errors
array $errors = 'array'
Details
- array
A collection of modProcessorResponseError objects for each field-specific error - visibility
- public
- default
- array
- final
- false
- static
- false
$modx
\modX $modx = 'null'
Details
-
\modX
A reference to the modX object - visibility
- public
- default
- null
- final
- false
- static
- false
$response
array $response = 'null'
Details
- array
A reference to the full response - visibility
- public
- default
- null
- final
- false
- static
- false
Methods
__construct
__construct(
\modX $modx, array $response
=
array
)
:
The constructor for modProcessorResponse
Arguments
- $modx
- \modX
A reference to the modX object. - $response
- array
The array response from the modX.runProcessor method
Details
- visibility
- public
- final
- false
- static
- false
getAllErrors
getAllErrors(
string $fieldErrorSeparator
=
:
)
:
array
Gets all errors and adds them all into an array.
Arguments
- $fieldErrorSeparator
- string
The separator to use between fieldkey and message for field-specific errors.
Output
- array
- An array of all errors.
Details
- visibility
- public
- final
- false
- static
- false
getErrorType
getErrorType(
)
:
string
Returns the type of error for this response
Output
- string
- The type of error returned
Details
- visibility
- public
- final
- false
- static
- false
getFieldErrors
getFieldErrors(
)
:
array
An array of modProcessorResponseError objects for each field-specific error
Output
- array
Details
- visibility
- public
- final
- false
- static
- false
getMessage
getMessage(
)
:
string
Gets the general status message for the response.
Output
- string
- The status message
Details
- visibility
- public
- final
- false
- static
- false
getObject
getObject(
)
:
array
Returns the array object, if is sent in the response
Output
- array
- The object in the response, usually the object being performed on.
Details
- visibility
- public
- final
- false
- static
- false
getResponse
getResponse(
)
:
array
Returns the entire response object in array form
Output
- array
- The array response
Details
- visibility
- public
- final
- false
- static
- false
hasFieldErrors
hasFieldErrors(
)
:
boolean
Checks to see if there are any field-specific errors in this response
Output
- boolean
- True if there were field-specific errors
Details
- visibility
- public
- final
- false
- static
- false
hasMessage
hasMessage(
)
:
boolean
Returns true if there is a general status message for the response.
Output
- boolean
- True if there is a general message
Details
- visibility
- public
- final
- false
- static
- false
hasObject
hasObject(
)
:
boolean
Returns true if an object was sent with this response.
Output
- boolean
- True if an object was sent.
Details
- visibility
- public
- final
- false
- static
- false
isError
isError(
)
:
\Returns
Checks to see if the response is an error
Output
- \Returns
- true if the response was a success, otherwise false
Details
- visibility
- public
- final
- false
- static
- false
\modProcessorResponseError
- package
- modx
- Properties
- $error
- $field
- $message
- Methods
- __construct
- getError
- getField
- getMessage
Description
An abstraction class of field-specific errors for a processor response
Properties
$error
array $error = 'null'
Details
- array
The error data itself - visibility
- public
- default
- null
- final
- false
- static
- false
$field
string $field = 'null'
Details
- string
The field key that the error occurred on - visibility
- public
- default
- null
- final
- false
- static
- false
$message
string $message = ''
Details
- string
The message that was sent for the field error - visibility
- public
- default
- final
- false
- static
- false
Methods
__construct
__construct(
array $error
=
array
)
:
The constructor for the modProcessorResponseError class
Arguments
- $error
- array
An array error response
Details
- visibility
- public
- final
- false
- static
- false
getError
getError(
)
:
array
Returns the array data for the field-specific error
Output
- array
Details
- visibility
- public
- final
- false
- static
- false
getField
getField(
)
:
Returns the field key for the field-specific error
Details
- visibility
- public
- final
- false
- static
- false
getMessage
getMessage(
)
:
string
Returns the message for the field-specific error
Output
- string
Details
- visibility
- public
- final
- false
- static
- false