class Result (View source)

Result object for operations dealing with objects, such as the Property Mapper or the Validators.

Properties

protected Error[] $errors
protected bool $errorsExist

Caches the existence of errors

protected Warning[] $warnings
protected bool $warningsExist

Caches the existence of warning

protected Notice[] $notices
protected bool $noticesExist

Caches the existence of notices

protected Result[] $propertyResults

The result objects for the sub properties

protected Result $parent

Methods

void
setParent(Result $parent)

Injects the parent result and propagates the cached error states upwards

void
addError(Error $error)

Add an error to the current Result object

void
addWarning(Warning $warning)

Add a warning to the current Result object

void
addNotice(Notice $notice)

Add a notice to the current Result object

array
getErrors(string $messageTypeFilter = null)

Get all errors in the current Result object (non-recursive)

array
getWarnings(string $messageTypeFilter = null)

Get all warnings in the current Result object (non-recursive)

array
getNotices(string $messageTypeFilter = null)

Get all notices in the current Result object (non-recursive)

getFirstError(string $messageTypeFilter = null)

Get the first error object of the current Result object (non-recursive)

getFirstWarning(string $messageTypeFilter = null)

Get the first warning object of the current Result object (non-recursive)

getFirstNotice(string $messageTypeFilter = null)

Get the first notice object of the current Result object (non-recursive)

forProperty(string $propertyPath = null)

Return a Result object for the given property path. This is a fluent interface, so you will probably use it like: $result->forProperty('foo.bar')->getErrors() -- to get all errors for property "foo.bar"

recurseThroughResult(array $pathSegments)

Internal use only!

bool
hasErrors()

Does the current Result object have Errors? (Recursively)

void
setErrorsExist()

Sets the error cache to true and propagates the information upwards the Result-Object Tree

bool
hasWarnings()

Does the current Result object have Warnings? (Recursively)

void
setWarningsExist()

Sets the warning cache to true and propagates the information upwards the Result-Object Tree

bool
hasNotices()

Does the current Result object have Notices? (Recursively)

void
setNoticesExist()

Sets the notices cache to true and propagates the information upwards the Result-Object Tree

bool
hasMessages()

Does the current Result object have Notices, Errors or Warnings? (Recursively)

array
getFlattenedErrors()

Get a list of all Error objects recursively. The result is an array, where the key is the property path where the error occurred, and the value is a list of all errors (stored as array)

array
getFlattenedErrorsOfType(string $type)

Get a list of all Error objects recursively. The result is an array, where the key is the property path where the error occurred, and the value is a list of all errors (stored as array)

array
getFlattenedWarnings()

Get a list of all Warning objects recursively. The result is an array, where the key is the property path where the warning occurred, and the value is a list of all warnings (stored as array)

array
getFlattenedNotices()

Get a list of all Notice objects recursively. The result is an array, where the key is the property path where the notice occurred, and the value is a list of all notices (stored as array)

void
flattenTree(string $propertyName, array $result, array $level = [], string $messageTypeFilter = null)

Flatten a tree of Result objects, based on a certain property.

array
filterMessages(array $messages, string $messageTypeFilter = null)

No description

void
merge(Result $otherResult)

Merge the given Result object into this one.

void
mergeProperty(Result $otherResult, string $getterName, string $adderName)

Merge a single property from the other result object.

array
getSubResults()

Get a list of all sub Result objects available.

void
clear()

Clears the result

Details

void setParent(Result $parent)

Injects the parent result and propagates the cached error states upwards

Parameters

Result $parent

Return Value

void

void addError(Error $error)

Add an error to the current Result object

Parameters

Error $error

Return Value

void

void addWarning(Warning $warning)

Add a warning to the current Result object

Parameters

Warning $warning

Return Value

void

void addNotice(Notice $notice)

Add a notice to the current Result object

Parameters

Notice $notice

Return Value

void

array getErrors(string $messageTypeFilter = null)

Get all errors in the current Result object (non-recursive)

Parameters

string $messageTypeFilter

if specified only errors implementing the given class are returned

Return Value

array

array getWarnings(string $messageTypeFilter = null)

Get all warnings in the current Result object (non-recursive)

Parameters

string $messageTypeFilter

if specified only warnings implementing the given class are returned

Return Value

array

array getNotices(string $messageTypeFilter = null)

Get all notices in the current Result object (non-recursive)

Parameters

string $messageTypeFilter

if specified only notices implementing the given class are returned

Return Value

array

Error getFirstError(string $messageTypeFilter = null)

Get the first error object of the current Result object (non-recursive)

Parameters

string $messageTypeFilter

if specified only errors implementing the given class are considered

Return Value

Error

Warning getFirstWarning(string $messageTypeFilter = null)

Get the first warning object of the current Result object (non-recursive)

Parameters

string $messageTypeFilter

if specified only warnings implementing the given class are considered

Return Value

Warning

Notice getFirstNotice(string $messageTypeFilter = null)

Get the first notice object of the current Result object (non-recursive)

Parameters

string $messageTypeFilter

if specified only notices implementing the given class are considered

Return Value

Notice

Result forProperty(string $propertyPath = null)

Return a Result object for the given property path. This is a fluent interface, so you will probably use it like: $result->forProperty('foo.bar')->getErrors() -- to get all errors for property "foo.bar"

Parameters

string $propertyPath

Return Value

Result

Result recurseThroughResult(array $pathSegments)

Internal use only!

Parameters

array $pathSegments

Return Value

Result

bool hasErrors()

Does the current Result object have Errors? (Recursively)

Return Value

bool

protected void setErrorsExist()

Sets the error cache to true and propagates the information upwards the Result-Object Tree

Return Value

void

bool hasWarnings()

Does the current Result object have Warnings? (Recursively)

Return Value

bool

protected void setWarningsExist()

Sets the warning cache to true and propagates the information upwards the Result-Object Tree

Return Value

void

bool hasNotices()

Does the current Result object have Notices? (Recursively)

Return Value

bool

protected void setNoticesExist()

Sets the notices cache to true and propagates the information upwards the Result-Object Tree

Return Value

void

bool hasMessages()

Does the current Result object have Notices, Errors or Warnings? (Recursively)

Return Value

bool

array getFlattenedErrors()

Get a list of all Error objects recursively. The result is an array, where the key is the property path where the error occurred, and the value is a list of all errors (stored as array)

Return Value

array

array getFlattenedErrorsOfType(string $type)

Get a list of all Error objects recursively. The result is an array, where the key is the property path where the error occurred, and the value is a list of all errors (stored as array)

Parameters

string $type

Return Value

array

array getFlattenedWarnings()

Get a list of all Warning objects recursively. The result is an array, where the key is the property path where the warning occurred, and the value is a list of all warnings (stored as array)

Return Value

array

array getFlattenedNotices()

Get a list of all Notice objects recursively. The result is an array, where the key is the property path where the notice occurred, and the value is a list of all notices (stored as array)

Return Value

array

void flattenTree(string $propertyName, array $result, array $level = [], string $messageTypeFilter = null)

Flatten a tree of Result objects, based on a certain property.

Parameters

string $propertyName
array $result

The current result to be flattened

array $level

The property path in the format array('level1', 'level2', ...) for recursion

string $messageTypeFilter

If specified only messages implementing the given class name are taken into account

Return Value

void

protected array filterMessages(array $messages, string $messageTypeFilter = null)

No description

Parameters

array $messages

an array of Message instances to filter

string $messageTypeFilter

If specified only messages implementing the given class name are taken into account

Return Value

array

the filtered message instances

void merge(Result $otherResult)

Merge the given Result object into this one.

Parameters

Result $otherResult

Return Value

void

protected void mergeProperty(Result $otherResult, string $getterName, string $adderName)

Merge a single property from the other result object.

Parameters

Result $otherResult
string $getterName
string $adderName

Return Value

void

array getSubResults()

Get a list of all sub Result objects available.

Return Value

array

void clear()

Clears the result

Return Value

void