model/modx/error/moderror.class.php

Classes 
package
modx
subpackage
error
Classes
modError

Description

Error handler for request/response processing.

\modError

abstract
Implement a derivative of this class for error handling and validation of any kind of MODX request.
package
modx
subpackage
error
Properties
$_objects
$errors
$message
$modx
$status
$total
Methods
__construct
_validate
addError
addField
addObjectToValidate
checkValidation
failure
getErrors
getFields
hasError
isFieldError
isNotFieldError
process
reset
success
toArray

Description

Abstract class for error handling and validation for requests.

Properties

$_objectsAn array of objects to validate against

array $_objects = 'array'

Details

array
An array of objects to validate against
visibility
protected
default
array
final
false
static
false

$errorsThe array of errors

array $errors = ''

Details

array
The array of errors
visibility
public
default
final
false
static
false

$messageThe error message to output.

string $message = ''

Details

string
The error message to output.
visibility
public
default
final
false
static
false

$modxA reference to the $modx object.

\modX $modx = ''

Details

\modX
A reference to the $modx object.
visibility
public
default
final
false
static
false

$statusIndicates failure or success.

boolean $status = 'false'

Details

boolean
Indicates failure or success.
visibility
public
default
false
final
false
static
false

$totalThe total number of errors.

integer $total = '0'

Details

integer
The total number of errors.
visibility
public
default
0
final
false
static
false

Methods

__construct

__construct( \modX $modx, string $message ) :

Arguments
$modx
\modX
A reference to the modX instance
$message
string
The default message to send as an error response
Details
visibility
public
final
false
static
false

_validate

_validate( ) : string

Grabs formatted validation messages for all objects in the validation queue.

Output
string
The compiled validation message returned.
Details
visibility
protected
final
false
static
false
access
protected

addError

addError( string|array $msg ) :

Add an error to the error queue.

Arguments
$msg
stringarray
An error message string or custom error array.
Details
visibility
public
final
false
static
false

addField

addField( string $name, string $error ) :

Add a specific field error to the error queue.

Arguments
$name
string
The id of the field.
$error
string
The error message.
Details
visibility
public
final
false
static
false

addObjectToValidate

addObjectToValidate( \xPDOObject $obj ) :

Adds an object to the validation queue.

Arguments
$obj
\xPDOObject
An xPDOObject to validate.
Details
visibility
public
final
false
static
false
access
public

checkValidation

checkValidation( \xPDOObject|array $objs = array ) : string

Checks validation, and if any errors are found, returns them. Error handlers that derive from this can determine their own behaviour should errors be found.

Arguments
$objs
\xPDOObjectarray
An xPDOObject or array of xPDOObjects to add to the validation queue.
Output
string
The validation message returned.
Details
visibility
public
final
false
static
false
access
public

failure

failure( string $message, object|array|string $object = null ) : string|array

Send a failure error message.

Arguments
$message
string
The error message to send.
$object
objectarraystring
An object to send back to the output.
Output
string|array
The failure response
Details
visibility
public
final
false
static
false

getErrors

getErrors( boolean $includeFields = false ) : array

Return all of the errors in the error queue.

Arguments
$includeFields
boolean
Whether or not to include the fields in the error response
Output
array
An array of errors
Details
visibility
public
final
false
static
false

getFields

getFields( ) : array

Return the fields added as errors.

Output
array
An array of errors for specific fields.
Details
visibility
public
final
false
static
false

hasError

hasError( ) : boolean

Check to see if there is any errors on the queue.

Output
boolean
True if there are errors or a message has been specified.
Details
visibility
public
final
false
static
false

isFieldError

isFieldError( mixed $error ) : boolean

Returns true if the error passed to it represents a field error.

Arguments
$error
mixed
An element of modError::errors.
Output
boolean
True if the error is a field error.
Details
visibility
public
final
false
static
false

isNotFieldError

isNotFieldError( mixed $error ) : boolean

Returns true if the error passed to it does not represent a field error.

Arguments
$error
mixed
An element of modError::errors.
Output
boolean
True if the error is not a field error.
Details
visibility
public
final
false
static
false

process

process( string $message, boolean $status = false, object|array $object = null ) : string|object|array

Process errors and return a proper output value.

Arguments
$message
string
The error message to output.
$status
boolean
Whether or not the action is a success or failure.
$object
objectarray
The object to send back to output.
Output
string|object|array
The transformed object data array.
Details
visibility
public
final
false
static
false

reset

reset( ) :

Resets the error messages.

Details
visibility
public
final
false
static
false

success

success( string $message, object|array|string $object = null ) : string|array

Send a success error message.

Arguments
$message
string
The error message to send.
$object
objectarraystring
An object to send back to the output.
Output
string|array
The success response
Details
visibility
public
final
false
static
false

toArray

toArray( array|object $object ) : array

Converts an object or objects embedded in an array, to arrays.

This function also makes sure that any members of the array are not PHP resource types (e.g. database connections, file handles, etc.).

Arguments
$object
arrayobject
An array or object to process.
Output
array
Returns an array representation of the object(s).
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox 0.11.2.