KMP PHP API Reference

ServiceResult
in package

Standardized result object for service layer operations.

Provides consistent success/failure status, error messages, and optional data. Used by WarrantManager, ActiveWindowManager, CsvExportService, etc.

Table of Contents

Properties

$data  : mixed
Optional data payload (entity IDs, entities, arrays, etc.).
$reason  : string|null
Human-readable error message (for failures) or informational message.
$success  : bool

Methods

__construct()  : mixed
getData()  : mixed
Get the data payload
getError()  : string|null
Get the error message
isSuccess()  : bool

Properties

$data

Optional data payload (entity IDs, entities, arrays, etc.).

public mixed $data = null

$reason

Human-readable error message (for failures) or informational message.

public string|null $reason = null

$success

public bool $success

Whether the operation succeeded

Methods

__construct()

public __construct(bool $success[, string|null $reason = null ][, mixed $data = null ]) : mixed
Parameters
$success : bool

Whether the operation succeeded

$reason : string|null = null

Optional explanation

$data : mixed = null

Optional data payload

getData()

Get the data payload

public getData() : mixed

Convenience method that returns the data property. Consider checking isSuccess() before calling this method.

Tags
example
if ($result->isSuccess()) {
    $id = $result->getData();
}
Return values
mixed

The data payload or null

getError()

Get the error message

public getError() : string|null

Convenience method that returns the reason property. Typically used when isSuccess() is false to get the error message.

Tags
example
if (!$result->isSuccess()) {
    $error = $result->getError();
    $this->Flash->error($error);
}
Return values
string|null

The error message or null


        
On this page

Search results