CoolCMS API

WorkSheetRepository extends ApiRepository
in package
uses BridgeFailureTrait

FinalYes

CRUD bridge to `api/company/work-sheet` plus two narrow actions for manual transitions of one work sheet: `close` (`open` to `closed`) and `reopen` (`closed`/`invoiced` to `open`).

WorkList is a job (historical name); WorkSheet is a work sheet inside a job. Follows WorkListRepository.

Table of Contents

Properties

$apiEndpoint  : string
Api presenter path (e.g. `api/system/page`); set by each concrete repository.
$bridge  : ApiBridge

Methods

__construct()  : mixed
closeSheet()  : Result
Closes a work sheet manually: `open` to `closed` (done, awaiting invoice).
delete()  : Result
deleteAll()  : Result
find()  : array<string|int, mixed>
findAll()  : array<string|int, mixed>
findBy()  : array<string|int, mixed>
reopenSheet()  : Result
Reopens a work sheet: `closed`/`invoiced` to `open`; requires its own privilege and keeps the invoice.
save()  : Result
updateColumns()  : Result
bridgeException()  : Result
Turns a caught bridge exception into `API_ERROR` without the exception text; the detail goes to the `admin.bridge` log channel.
bridgeMessage()  : string|null
Returns the message of a flat bridge response: null for a failure with a technical code (detail goes to the log), otherwise unchanged.
failSoftRead()  : array<string|int, mixed>
Normalizes a bridge response to plain data; a failed envelope or a non-array gives `[]`.
getApiCallSource()  : string
Branch marker for writes ({@see ApiBridge::PARAM_SOURCE}), read by the shared repository `SaveTrait`.
resultFromTransitionResponse()  : Result

Properties

$apiEndpoint

Api presenter path (e.g. `api/system/page`); set by each concrete repository.

protected string $apiEndpoint = 'api/company/work-sheet'

Methods

closeSheet()

Closes a work sheet manually: `open` to `closed` (done, awaiting invoice).

public closeSheet(int $id) : Result
Parameters
$id : int
Return values
Result

delete()

public delete(int|array<string|int, mixed> $id) : Result
Parameters
$id : int|array<string|int, mixed>
Return values
Result

deleteAll()

public deleteAll([array<string|int, mixed> $filters = [] ]) : Result
Parameters
$filters : array<string|int, mixed> = []
Return values
Result

find()

public find(int $id[, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : array<string|int, mixed>
Parameters
$id : int
$includes : string|array<string|int, mixed> = []
$useCache : bool|null = null
Return values
array<string|int, mixed>

findAll()

public findAll([array<string|int, mixed>|null $filters = [] ][, array<string|int, mixed>|null $orderBys = null ][, int|null $offset = null ][, int|null $limit = null ][, array<string|int, mixed>|null $columns = null ][, bool $computeTotalCount = false ][, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : array<string|int, mixed>
Parameters
$filters : array<string|int, mixed>|null = []
$orderBys : array<string|int, mixed>|null = null
$offset : int|null = null
$limit : int|null = null
$columns : array<string|int, mixed>|null = null
$computeTotalCount : bool = false
$includes : string|array<string|int, mixed> = []
$useCache : bool|null = null
Return values
array<string|int, mixed>

findBy()

public findBy([array<string|int, mixed>|null $filters = [] ][, string|array<string|int, mixed> $includes = [] ][, bool|null $useCache = null ]) : array<string|int, mixed>
Parameters
$filters : array<string|int, mixed>|null = []
$includes : string|array<string|int, mixed> = []
$useCache : bool|null = null
Return values
array<string|int, mixed>

reopenSheet()

Reopens a work sheet: `closed`/`invoiced` to `open`; requires its own privilege and keeps the invoice.

public reopenSheet(int $id) : Result
Parameters
$id : int
Return values
Result

save()

public save(array<string, mixed> $data[, array<string, mixed> $meta = [] ][, array<int, string> $skipFields = [] ]) : Result
Parameters
$data : array<string, mixed>

extracted entity payload

$meta : array<string, mixed> = []
$skipFields : array<int, string> = []
Return values
Result

updateColumns()

public updateColumns(array<string|int, mixed> $ids, array<string, mixed> $values) : Result
Parameters
$ids : array<string|int, mixed>

ids or composite-id arrays

$values : array<string, mixed>

property name => new value

Return values
Result

bridgeException()

Turns a caught bridge exception into `API_ERROR` without the exception text; the detail goes to the `admin.bridge` log channel.

protected bridgeException(Throwable $e, string $endpoint) : Result
Parameters
$e : Throwable
$endpoint : string
Return values
Result

bridgeMessage()

Returns the message of a flat bridge response: null for a failure with a technical code (detail goes to the log), otherwise unchanged.

protected bridgeMessage(array<string, mixed> $response, ResultCode $code, string $endpoint) : string|null
Parameters
$response : array<string, mixed>
$code : ResultCode
$endpoint : string
Return values
string|null

failSoftRead()

Normalizes a bridge response to plain data; a failed envelope or a non-array gives `[]`.

protected failSoftRead(mixed $response, string $endpoint) : array<string|int, mixed>

NOTE: it does not log on purpose. ApiBridge::call(), which sees both the endpoint and the caller, has already written the API_FAILSOFT source=bridge line; a second copy would turn one failure into three lines in auth.log.

Parameters
$response : mixed
$endpoint : string

only for call readability; the log takes the endpoint from the bridge

Return values
array<string|int, mixed>

getApiCallSource()

Branch marker for writes ({@see ApiBridge::PARAM_SOURCE}), read by the shared repository `SaveTrait`.

protected getApiCallSource() : string
Return values
string

resultFromTransitionResponse()

private resultFromTransitionResponse(mixed $response) : Result
Parameters
$response : mixed
Return values
Result
On this page

Search results