core/model/modx/error/moderror.class.php

Show: inherited
Table of Contents

Error handler for request/response processing.

Package
modx  
Subpackage
error  

\modError

Package: modx\error

Abstract class for error handling and validation for requests.

Abstract
Implement a derivative of this class for error handling and validation of any kind of MODX request.  

Properties

Propertyprotectedarray  $_objects= 'array()'

An array of objects to validate against
Default valuearray()Details
Type
array
Propertypublicarray  $errors= ''

The array of errors
Details
Type
array
Propertypublicstring  $message= ''

The error message to output.
Details
Type
string
Propertypublic\modX  $modx= ''

A reference to the $modx object.
Details
Type
\modX
Propertypublicboolean  $status= 'false'

Indicates failure or success.
Default valuefalseDetails
Type
boolean
Propertypublicinteger  $total= '0'

The total number of errors.
Default value0Details
Type
integer

Methods

methodpublic__construct( \modX $modx, string $message = '' ) : void

Parameters
Name Type Description
$modx \modX

A reference to the modX instance

$message string

The default message to send as an error response

methodprotected_validate( ) : string

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

Returns
Type Description
string The compiled validation message returned.
Details
Access
protected  
methodpublicaddError( string | array $msg ) : void

Add an error to the error queue.

Parameters
Name Type Description
$msg string | array

An error message string or custom error array.

methodpublicaddField( string $name, string $error ) : void

Add a specific field error to the error queue.

Parameters
Name Type Description
$name string

The id of the field.

$error string

The error message.

methodpublicaddObjectToValidate( \xPDOObject $obj ) : void

Adds an object to the validation queue.

Parameters
Name Type Description
$obj \xPDOObject

An xPDOObject to validate.

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

Parameters
Name Type Description
$objs \xPDOObject | array

An xPDOObject or array of xPDOObjects to add to the validation queue.

Returns
Type Description
string The validation message returned.
Details
Access
public  
methodpublicfailure( string $message = '', object | array | string $object = null ) : string | array

Send a failure error message.

Parameters
Name Type Description
$message string

The error message to send.

$object object | array | string

An object to send back to the output.

Returns
Type Description
string | array The failure response
methodpublicgetErrors( boolean $includeFields = false ) : array

Return all of the errors in the error queue.

Parameters
Name Type Description
$includeFields boolean

Whether or not to include the fields in the error response

Returns
Type Description
array An array of errors
methodpublicgetFields( ) : array

Return the fields added as errors.

Returns
Type Description
array An array of errors for specific fields.
methodpublichasError( ) : boolean

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

Returns
Type Description
boolean True if there are errors or a message has been specified.
methodpublicisFieldError( mixed $error ) : boolean

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

Parameters
Name Type Description
$error mixed

An element of modError::errors.

Returns
Type Description
boolean True if the error is a field error.
methodpublicisNotFieldError( mixed $error ) : boolean

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

Parameters
Name Type Description
$error mixed

An element of modError::errors.

Returns
Type Description
boolean True if the error is not a field error.
methodpublicprocess( string $message = '', boolean $status = false, object | array $object = null ) : string | object | array

Process errors and return a proper output value.

Parameters
Name Type Description
$message string

The error message to output.

$status boolean

Whether or not the action is a success or failure.

$object object | array

The object to send back to output.

Returns
Type Description
string | object | array The transformed object data array.
methodpublicreset( ) : void

Resets the error messages.

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

Send a success error message.

Parameters
Name Type Description
$message string

The error message to send.

$object object | array | string

An object to send back to the output.

Returns
Type Description
string | array The success response
methodpublictoArray( array | \xPDOObject | 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.).

Parameters
Name Type Description
$object array | \xPDOObject | object

An array or object to process.

Returns
Type Description
array Returns an array representation of the object(s).
Documentation was generated by DocBlox 0.18.1.