class Result (View source)

An immutable result object often detailing the result of a registration or validation completed by the respective handlers

Traits

A class that can be instantiated or replaced via DI

Properties

protected bool $success

Indicates this result was successful

protected string $message

An message describing the result

protected array $context

Context provided by the handler returning this result

Methods

public static 
create(bool $success = true, string $message = '', array $context = [])

No description

public static 
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

public
__construct(bool $success = true, string $message = '', array $context = [])

No description

public
bool
isSuccessful()

No description

public
string
getMessage()

No description

public
array
getContext()

No description

public
setSuccessful(bool $success)

No description

public
setMessage(string $message)

No description

public
setContext(array $context)

No description

Details

static Result create(bool $success = true, string $message = '', array $context = [])

No description

Parameters

bool $success
string $message
array $context

Return Value

Result

static Injectable singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).

Parameters

string $class

Optional classname to create, if the called class should not be used

Return Value

Injectable

The singleton instance

__construct(bool $success = true, string $message = '', array $context = [])

No description

Parameters

bool $success
string $message
array $context

bool isSuccessful()

No description

Return Value

bool

string getMessage()

No description

Return Value

string

array getContext()

No description

Return Value

array

Result setSuccessful(bool $success)

No description

Parameters

bool $success

Return Value

Result

Result setMessage(string $message)

No description

Parameters

string $message

Return Value

Result

Result setContext(array $context)

No description

Parameters

array $context

Return Value

Result