CoolCMS API

ProductSetRepository extends ApiRepository
in package

FinalYes

Admin repository that reads through the Api bridge and bypasses the query cache by default.

find(), findBy() and findAll() send ApiBridge::PARAM_USE_CACHE = false. $useCache is ?bool: null leaves the decision to this layer (false); an explicit true (->useCache(true) on the query) is respected and is the only way to request the cache.

IMPORTANT: an admin form is a read followed by a write, so a stale cached value would be written back to the DB (silent data regression). Invalidation cannot cover it: the view counters (views, viewsList, viewsDetail) are deliberately excluded from it (SaveTrait::$nonInvalidatingColumns), because bumping on every detail view would drop the cache of all lists.

NOTE: this default is not the only safeguard. The main switch is QueryCacheContext, turned off for the whole request by BasePresenter::startup(), because an admin request also runs front managers (AssetManager, ThemeManager, UserManager) through the front repository. This default covers admin reads outside an admin request (CLI harness, admin cron).

Table of Contents

Properties

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

Methods

__construct()  : mixed
delete()  : Result
deleteAll()  : Result
deletePriceSnapshot()  : array{success: bool, code: string}
Deletes a whole price snapshot through the bridge action `.../delete-price-snapshot`.
fetchAvailability()  : array<int, array{availableSets: ?int, inStock: bool, deliveryDays: ?int, labelWarehouseId: ?int, infoText: ?string, attributeClass: ?string, unmappedVariantIds: list, unresolvedSetIds: list, inactiveSetIds: list}>
Returns the availability of product sets in a batch (constant number of queries), computed by {@see \App\UI\Api\Eshop\Models\Managers\ProductSetManager::getAvailabilities()} on the Api side (decomposes the set into stock items, plus `StockReader`). Bridge action `.../availability` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionAvailability()}).
fetchCurrentPrices()  : array<int, array{price: string, originalPrice: string, points: int, fromAmount: int, currencyId: int, vat: string, withVat: bool}>
Returns the currently valid prices of product sets in a batch (one SQL query), computed by `PriceResolver` on the Api side. The admin must not call Api services directly (`app/UI/Admin` imports nothing from `App\UI\Api\*`), so it goes through the bridge action `.../current-prices` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionCurrentPrices()}).
fetchDefaults()  : array{userGroupId: int, currencyId: int, paymentRegionId: int}
Returns the default catalog axes (base user group, default currency, default payment region) needed when the admin writes a price, through the bridge action `.../defaults` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionDefaults()}).
find()  : array<string|int, mixed>
findAll()  : array<string|int, mixed>
findBy()  : array<string|int, mixed>
save()  : Result
savePriceSnapshot()  : array{success: bool, code: string}
Saves or replaces a price snapshot through the bridge action `.../save-price-snapshot` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionSavePriceSnapshot()}).
softDelete()  : Result
Soft deletes without a cascade through the bridge action `.../soft-delete` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionSoftDelete()}). Has the same `int|array` signature and behavior as the generic {@see delete()} (group deletion in the grid sends an array of ids), only the bridge action differs.
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`.
callSnapshotAction()  : array{success: bool, code: string}
Calls any of the snapshot bridge actions; all return `['success' => bool, 'code' => string]` (`OK`/`IMMUTABLE`/`TIME_COLLISION`/`NOT_FOUND`/`VALIDATION`).

Properties

$apiEndpoint

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

protected string $apiEndpoint = 'api/eshop/product-set'

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

deletePriceSnapshot()

Deletes a whole price snapshot through the bridge action `.../delete-price-snapshot`.

public deletePriceSnapshot(int $id, string $publishedTime) : array{success: bool, code: string}
Parameters
$id : int
$publishedTime : string
Return values
array{success: bool, code: string}

fetchAvailability()

Returns the availability of product sets in a batch (constant number of queries), computed by {@see \App\UI\Api\Eshop\Models\Managers\ProductSetManager::getAvailabilities()} on the Api side (decomposes the set into stock items, plus `StockReader`). Bridge action `.../availability` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionAvailability()}).

public fetchAvailability(array<string|int, int> $ids[, int|null $languageId = null ]) : array<int, array{availableSets: ?int, inStock: bool, deliveryDays: ?int, labelWarehouseId: ?int, infoText: ?string, attributeClass: ?string, unmappedVariantIds: list, unresolvedSetIds: list, inactiveSetIds: list}>
Parameters
$ids : array<string|int, int>
$languageId : int|null = null
Return values
array<int, array{availableSets: ?int, inStock: bool, deliveryDays: ?int, labelWarehouseId: ?int, infoText: ?string, attributeClass: ?string, unmappedVariantIds: list, unresolvedSetIds: list, inactiveSetIds: list}>

fetchCurrentPrices()

Returns the currently valid prices of product sets in a batch (one SQL query), computed by `PriceResolver` on the Api side. The admin must not call Api services directly (`app/UI/Admin` imports nothing from `App\UI\Api\*`), so it goes through the bridge action `.../current-prices` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionCurrentPrices()}).

public fetchCurrentPrices(array<string|int, int> $ids[, int|null $userGroupId = null ][, int|null $currencyId = null ][, int $amount = 1 ]) : array<int, array{price: string, originalPrice: string, points: int, fromAmount: int, currencyId: int, vat: string, withVat: bool}>
Parameters
$ids : array<string|int, int>
$userGroupId : int|null = null
$currencyId : int|null = null
$amount : int = 1
Return values
array<int, array{price: string, originalPrice: string, points: int, fromAmount: int, currencyId: int, vat: string, withVat: bool}>

fetchDefaults()

Returns the default catalog axes (base user group, default currency, default payment region) needed when the admin writes a price, through the bridge action `.../defaults` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionDefaults()}).

public fetchDefaults() : array{userGroupId: int, currencyId: int, paymentRegionId: int}
Return values
array{userGroupId: int, currencyId: int, paymentRegionId: int}

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>

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

savePriceSnapshot()

Saves or replaces a price snapshot through the bridge action `.../save-price-snapshot` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionSavePriceSnapshot()}).

public savePriceSnapshot(int $id, string|null $publishedTime, array<int, array{fromAmount: int, userGroupId: int, currencyId: int, price: string|float, originalPrice: string|float|null, points: int}> $rows[, string|null $replaceTime = null ]) : array{success: bool, code: string}

replaceTime is the publishedTime of the edited snapshot (null adds a new one).

Parameters
$id : int
$publishedTime : string|null
$rows : array<int, array{fromAmount: int, userGroupId: int, currencyId: int, price: string|float, originalPrice: string|float|null, points: int}>
$replaceTime : string|null = null
Return values
array{success: bool, code: string}

softDelete()

Soft deletes without a cascade through the bridge action `.../soft-delete` ({@see \App\UI\Api\Eshop\Presenters\ProductSetPresenter::internalActionSoftDelete()}). Has the same `int|array` signature and behavior as the generic {@see delete()} (group deletion in the grid sends an array of ids), only the bridge action differs.

public softDelete(int|array<int, int> $id) : Result
Parameters
$id : int|array<int, int>
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

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

callSnapshotAction()

Calls any of the snapshot bridge actions; all return `['success' => bool, 'code' => string]` (`OK`/`IMMUTABLE`/`TIME_COLLISION`/`NOT_FOUND`/`VALIDATION`).

private callSnapshotAction(string $action, array<string, mixed> $params) : array{success: bool, code: string}
Parameters
$action : string
$params : array<string, mixed>
Return values
array{success: bool, code: string}
On this page

Search results