final class RecordWriteResult (View source)

Outcome of a record write. Replaces the bool return plus MessageService side channel: callers read the reason, the refusal and the offending record part from here instead of the session.

Methods

previewed(array|null $vacates, array $key)

An edit that passed validation and the permission checks in a preview, nothing written.

saved(array $key)

An edit that was written.

ok(int|string|null $recordId = null)

No description

unchanged()

A save that matched the stored record and was skipped, so nothing was written.

failure(string $message, Refusal $refusal = Refusal::INVALID_INPUT, RecordField|null $field = null)

No description

forbidden(string $message)

No description

notFound(string $message)

No description

backendFailure(string $message, RecordField|null $field = null)

No description

backendRejected(string $message, string $reason, RecordField|null $field = null)

The backend answered and refused the write; $reason is its own sanitised text and $message already carries it.

Details

static RecordWriteResult previewed(array|null $vacates, array $key)

An edit that passed validation and the permission checks in a preview, nothing written.

Parameters

array|null $vacates

The stored name, type and content the record leaves, or null when they stay

array $key

The validated name, type and content

Return Value

RecordWriteResult

static RecordWriteResult saved(array $key)

An edit that was written.

Parameters

array $key

The validated name, type and content it was stored under

Return Value

RecordWriteResult

static RecordWriteResult ok(int|string|null $recordId = null)

No description

Parameters

int|string|null $recordId

The new id on create; edits and deletes carry none

Return Value

RecordWriteResult

static RecordWriteResult unchanged()

A save that matched the stored record and was skipped, so nothing was written.

Return Value

RecordWriteResult

static RecordWriteResult failure(string $message, Refusal $refusal = Refusal::INVALID_INPUT, RecordField|null $field = null)

No description

Parameters

string $message
Refusal $refusal
RecordField|null $field

The record part the message is about, when the validator named one

Return Value

RecordWriteResult

static RecordWriteResult forbidden(string $message)

No description

Parameters

string $message

Return Value

RecordWriteResult

static RecordWriteResult notFound(string $message)

No description

Parameters

string $message

Return Value

RecordWriteResult

static RecordWriteResult backendFailure(string $message, RecordField|null $field = null)

No description

Parameters

string $message
RecordField|null $field

Return Value

RecordWriteResult

static RecordWriteResult backendRejected(string $message, string $reason, RecordField|null $field = null)

The backend answered and refused the write; $reason is its own sanitised text and $message already carries it.

Parameters

string $message
string $reason
RecordField|null $field

Return Value

RecordWriteResult