class ErrorList implements ArrayAccess, JsonSerializable (View source)

Properties

protected ErrorInterface[] $errors

Methods

string
__toString()

No description

offsetExists($offset)

{@inheritdoc}

offsetGet($offset)

{@inheritdoc}

offsetSet($offset, $value)

{@inheritdoc}

offsetUnset($offset)

{@inheritdoc}

$this
addError(ErrorInterface|Exception|Throwable|ErrorList|string $e, bool $isHtml = false, string|null $fieldName = null, string|null $fieldDisplayName = null)

Add an error message/object or exception to the internal error array.

$this
add(Exception|Throwable|ErrorList|string $e, string|null $fieldName = null, string|null $fieldDisplayName = null)

Add an error message/object or exception to the internal error array (error messages are in plain text if not otherwise specified).

$this
addHtml(ErrorInterface|Exception|Throwable|ErrorList|string $e, string|null $fieldName = null, string|null $fieldDisplayName = null)

Add an error message/object or exception to the internal error array (error messages are in HTML if not otherwise specified).

getList()

Get the list of errors contained in this error list.

bool
has()

Returns whether or not this error list has more than one error registered within it.

string
output() deprecated

No description

string
outputJSON() deprecated

No description

array|null
jsonSerialize()

{@inheritdoc}

string
toText()

Render this error list as a plain text.

bool
containsField(FieldInterface|string $field)

Does this list contain error associated to a field?

string|false
getMessage(FieldInterface|string $field)

Get the error message (if any) associated to a field.

JsonResponse
createResponse(int $errorCode = JsonResponse::HTTP_BAD_REQUEST)

Create a JSON response describing the errors in this list.

Details

string __toString()

Return Value

string

offsetExists($offset)

{@inheritdoc}

Parameters

$offset

See also

\ArrayAccess::offsetExists()

ErrorInterface|null offsetGet($offset)

{@inheritdoc}

Parameters

$offset

Return Value

ErrorInterface|null

See also

\ArrayAccess::offsetGet()

offsetSet($offset, $value)

{@inheritdoc}

Parameters

$offset
$value

See also

\ArrayAccess::offsetSet()

offsetUnset($offset)

{@inheritdoc}

Parameters

$offset

See also

\ArrayAccess::offsetUnset()

$this addError(ErrorInterface|Exception|Throwable|ErrorList|string $e, bool $isHtml = false, string|null $fieldName = null, string|null $fieldDisplayName = null)

Add an error message/object or exception to the internal error array.

Parameters

ErrorInterface|Exception|Throwable|ErrorList|string $e the error(s) to be added
bool $isHtml set to true if error messages are in HTML format if not otherwise specified
string|null $fieldName
string|null $fieldDisplayName

Return Value

$this

$this add(Exception|Throwable|ErrorList|string $e, string|null $fieldName = null, string|null $fieldDisplayName = null)

Add an error message/object or exception to the internal error array (error messages are in plain text if not otherwise specified).

Parameters

Exception|Throwable|ErrorList|string $e the error(s) to be added
string|null $fieldName
string|null $fieldDisplayName

Return Value

$this

$this addHtml(ErrorInterface|Exception|Throwable|ErrorList|string $e, string|null $fieldName = null, string|null $fieldDisplayName = null)

Add an error message/object or exception to the internal error array (error messages are in HTML if not otherwise specified).

Parameters

ErrorInterface|Exception|Throwable|ErrorList|string $e the error(s) to be added
string|null $fieldName
string|null $fieldDisplayName

Return Value

$this

ErrorInterface[] getList()

Get the list of errors contained in this error list.

Return Value

ErrorInterface[]

bool has()

Returns whether or not this error list has more than one error registered within it.

Return Value

bool

string output() deprecated

deprecated Use the StandardFormatter class

Return Value

string

See also

\Concrete\Core\Error\ErrorList\Formatter\StandardFormatter

string outputJSON() deprecated

deprecated Use the JsonFormatter class

Return Value

string

See also

\Concrete\Core\Error\ErrorList\Formatter\JsonFormatter

array|null jsonSerialize()

{@inheritdoc}

Return Value

array|null

See also

\JsonSerializable::jsonSerialize()

string toText()

Render this error list as a plain text.

Return Value

string

bool containsField(FieldInterface|string $field)

Does this list contain error associated to a field?

Parameters

FieldInterface|string $field

Return Value

bool

string|false getMessage(FieldInterface|string $field)

Get the error message (if any) associated to a field.

Parameters

FieldInterface|string $field

Return Value

string|false false if no error is associated to the field, a string otherwise

JsonResponse createResponse(int $errorCode = JsonResponse::HTTP_BAD_REQUEST)

Create a JSON response describing the errors in this list.

Parameters

int $errorCode The HTTP response code to be sent to the client

Return Value

JsonResponse