CoolCMS API

ApiClientRepository extends ApiRepository
in package

FinalYes

External Api clients: endpoint `api/system/api-client`.

There is no generic CRUD (the Api has none; the key digest must be neither writable nor readable), so each operation has its own action. The bridge passes the parameter array as named arguments of internalAction*(), so the keys id / keyId / values / enabled match the parameter names in ApiClientPresenter.

IMPORTANT: create and issue-key return the readable key in data.key. Never log the result here, not even on error, or the key leaks into the logs.

Table of Contents

Properties

$apiEndpoint  : string
Api presenter path (e.g. `api/system/page`); set by each concrete repository.
$bridge  : ApiBridge
$overview  : array{clients: list>, defaultLimits: array}|null

Methods

__construct()  : mixed
create()  : Result
delete()  : Result
deleteAll()  : Result
deleteKey()  : Result
find()  : array<string|int, mixed>
findAll()  : array<string|int, mixed>
findBy()  : array<string|int, mixed>
getClient()  : array<string, mixed>|null
getOverview()  : array{clients: list>, defaultLimits: array}|null
Returns the clients and the default limits. Read once per request (grid and form both need it); every write clears this cache.
getRoleOptions()  : array<int, array<string, mixed>>
issueKey()  : Result
Issues another application key; `$expiresAt` is `Y-m-d\TH:i` or `null` for no expiry.
revoke()  : Result
revokeKey()  : Result
save()  : Result
setEnabled()  : Result
update()  : Result
updateColumns()  : Result
updateKey()  : Result
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`.
read()  : array<string|int, mixed>|null
row()  : array<string, mixed>
rows()  : array<int, array<string, mixed>>
write()  : Result

Properties

$apiEndpoint

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

protected string $apiEndpoint = 'api/system/api-client'

$overview

private array{clients: list>, defaultLimits: array}|null $overview = null

per-request overview cache

Methods

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>

getClient()

public getClient(int $id) : array<string, mixed>|null
Parameters
$id : int
Return values
array<string, mixed>|null —

one client; null when missing or the Api returned no data

getOverview()

Returns the clients and the default limits. Read once per request (grid and form both need it); every write clears this cache.

public getOverview() : array{clients: list>, defaultLimits: array}|null
Return values
array{clients: list>, defaultLimits: array}|null —

null when the Api returned no data

getRoleOptions()

public getRoleOptions() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>> —

roles that can be granted to a client (with privileged, default flags)

issueKey()

Issues another application key; `$expiresAt` is `Y-m-d\TH:i` or `null` for no expiry.

public issueKey(int $id, string|null $label, string|null $expiresAt) : Result
Parameters
$id : int
$label : string|null
$expiresAt : string|null
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

update()

public update(int $id, array<string, mixed> $values) : Result
Parameters
$id : int
$values : array<string, mixed>
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

updateKey()

public updateKey(int $id, int $keyId, string|null $label, string|null $expiresAt) : Result
Parameters
$id : int
$keyId : int
$label : string|null
$expiresAt : string|null
Return values
Result

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

read()

private read(string $action, array<string, mixed> $params) : array<string|int, mixed>|null
Parameters
$action : string
$params : array<string, mixed>
Return values
array<string|int, mixed>|null —

data of a successful response

row()

private static row(array<string|int, mixed> $item) : array<string, mixed>
Parameters
$item : array<string|int, mixed>
Return values
array<string, mixed>

rows()

private static rows(array<string|int, mixed> $items) : array<int, array<string, mixed>>
Parameters
$items : array<string|int, mixed>
Return values
array<int, array<string, mixed>>

write()

private write(string $action, array<string, mixed> $params) : Result
Parameters
$action : string
$params : array<string, mixed>
Return values
Result
On this page

Search results