CustomAssetRepository
extends ApiRepository
in package
Bridge to the Api operations of the custom code library. The library has no scope, see {@see \App\UI\Api\System\Models\Managers\Traits\CustomAssetLibraryTrait}.
Table of Contents
Properties
- $apiEndpoint : string
- Api presenter path (e.g. `api/system/page`); set by each concrete repository.
- $bridge : ApiBridge
Methods
- __construct() : mixed
- attachAllPages() : Result
- Adds the code to all pages (idempotent `INSERT IGNORE`).
- delete() : Result
- deleteAll() : Result
- detachAllPages() : Result
- Removes the code from all pages; the code itself stays.
- find() : array<string|int, mixed>
- findAll() : array<string|int, mixed>
- findBy() : array<string|int, mixed>
- save() : Result
- saveAsset() : Result
- Saves one code (new or existing). Does not touch page links.
- syncPage() : Result
- Replaces the whole set of codes of one page (the custom code tab of the page form).
- updateColumns() : 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`.
- postCustomAssetOperation() : Result
- Calls the bridge and unwraps the response envelope.
Properties
$apiEndpoint
Api presenter path (e.g. `api/system/page`); set by each concrete repository.
protected
string
$apiEndpoint
= 'api/system/custom-asset'
$bridge read-only
protected
ApiBridge
$bridge
Methods
__construct()
public
__construct(ApiBridge $bridge) : mixed
Parameters
- $bridge : ApiBridge
attachAllPages()
Adds the code to all pages (idempotent `INSERT IGNORE`).
public
attachAllPages(int $assetId) : Result
Parameters
- $assetId : int
Return values
Resultdelete()
public
delete(int|array<string|int, mixed> $id) : Result
Parameters
- $id : int|array<string|int, mixed>
Return values
ResultdeleteAll()
public
deleteAll([array<string|int, mixed> $filters = [] ]) : Result
Parameters
- $filters : array<string|int, mixed> = []
Return values
ResultdetachAllPages()
Removes the code from all pages; the code itself stays.
public
detachAllPages(int $assetId) : Result
Parameters
- $assetId : int
Return values
Resultfind()
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>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
ResultsaveAsset()
Saves one code (new or existing). Does not touch page links.
public
saveAsset(array<string, mixed> $asset) : Result
Parameters
- $asset : array<string, mixed>
Return values
ResultsyncPage()
Replaces the whole set of codes of one page (the custom code tab of the page form).
public
syncPage(int $pageId, array<int, int> $assetIds) : Result
Parameters
- $pageId : int
- $assetIds : array<int, int>
Return values
ResultupdateColumns()
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
ResultfailSoftRead()
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
stringpostCustomAssetOperation()
Calls the bridge and unwraps the response envelope.
private
postCustomAssetOperation(string $action, array<string, mixed> $payload) : Result
Parameters
- $action : string
- $payload : array<string, mixed>