trait Errors

Errors trait

Properties

protected Closure|null $dataValidCallback Data validatin callback
protected Closure|null $dataErrorCallback Data error callback
protected array|null $validationErrorMessages Validation error messages
protected array $errors Errors list

Methods

void
setErrors(array $errors)

Set errors

ApiController
error(string $name, array $params = [])

Set error, first find in messages array if not found display name value as error

void
addError(string $errorCode)

Add system error

string|null
getValidationErrorMessage(string $code)

Get validaiton error message

void
addErrors(array $errors)

Add errors

int
getErrorCount()

Return errors count

bool
hasError()

Return true if response have error

Self
withError(string $errorMessage, bool $condition = true)

Set error message

void
setError(string $errorMessage, bool $condition = true)

Set error message

void
clearErrors()

Clear all errors.

void
onValidationError(Closure $callback)

Set callback for validation errors

void
onDataValid(Closure $callback)

Set callback for validation done

Closure|null
getDataValidCallback()

Get data validation callback

Closure|null
getValidationErrorCallback()

Get validation error callback

void
loadValidationErrors()

Load validation error messages

array
resolveValidationErrors(array $errors)

Resolve validation errors

Details

at line 54
void setErrors(array $errors)

Set errors

Parameters

array $errors

Return Value

void

at line 66
ApiController error(string $name, array $params = [])

Set error, first find in messages array if not found display name value as error

Parameters

string $name
array $params

Return Value

ApiController

at line 85
void addError(string $errorCode)

Add system error

Parameters

string $errorCode

Return Value

void

at line 99
protected string|null getValidationErrorMessage(string $code)

Get validaiton error message

Parameters

string $code

Return Value

string|null

at line 110
void addErrors(array $errors)

Add errors

Parameters

array $errors

Return Value

void

at line 120
int getErrorCount()

Return errors count

Return Value

int

at line 130
bool hasError()

Return true if response have error

Return Value

bool

at line 142
Self withError(string $errorMessage, bool $condition = true)

Set error message

Parameters

string $errorMessage
bool $condition

Return Value

Self

at line 156
void setError(string $errorMessage, bool $condition = true)

Set error message

Parameters

string $errorMessage
bool $condition

Return Value

void

at line 168
void clearErrors()

Clear all errors.

Return Value

void

at line 179
void onValidationError(Closure $callback)

Set callback for validation errors

Parameters

Closure $callback

Return Value

void

at line 190
void onDataValid(Closure $callback)

Set callback for validation done

Parameters

Closure $callback

Return Value

void

at line 200
Closure|null getDataValidCallback()

Get data validation callback

Return Value

Closure|null

at line 210
Closure|null getValidationErrorCallback()

Get validation error callback

Return Value

Closure|null

at line 220
void loadValidationErrors()

Load validation error messages

Return Value

void

at line 236
protected array resolveValidationErrors(array $errors)

Resolve validation errors

Parameters

array $errors

Return Value

array