FeedRepository
extends ApiRepository
in package
Bridge repository of the feed: generic CRUD (save, get-all, delete) plus dedicated actions outside the generic save (see {@see \App\UI\Api\Eshop\Models\Managers\FeedManager}).
Four of the actions are scoped (to a product set or a category), so the overrides and the category mappings are edited where they belong, outside the feed form.
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
- find() : array<string|int, mixed>
- findAll() : array<string|int, mixed>
- findBy() : array<string|int, mixed>
- getCategoryRels() : array<int, array<string, mixed>>
- Returns the mapping of a single category to a value per feed (category form).
- getParameterRels() : array<int, array<string, mixed>>
- getParameterRelsForSet() : array<int, array<string, mixed>>
- Returns the overrides of a single product set across all feeds ("Feeds" tab of the set).
- getParameterTree() : array<int, array<string, mixed>>
- save() : Result
- saveCategoryRels() : array{success: bool, message: ?string, data: mixed, code: ?int}
- Saves the category mapping. The delete is scoped to `category_id` only.
- saveParameterRels() : array{success: bool, message: ?string, data: mixed, code: ?int}
- saveParameterRelsForSet() : array{success: bool, message: ?string, data: mixed, code: ?int}
- Saves the overrides of one product set. The delete is scoped to `product_set_id` only.
- saveParameterTree() : array{success: bool, message: ?string, data: mixed, code: ?int}
- 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`.
- normalizeResult() : array{success: bool, message: ?string, data: mixed, code: ?int}
- normalizeRows() : array<int, array<string, mixed>>
- Normalizes the untyped bridge payload to a list of rows with string keys.
Properties
$apiEndpoint
Api presenter path (e.g. `api/system/page`); set by each concrete repository.
protected
string
$apiEndpoint
= 'api/eshop/feed'
$bridge read-only
protected
ApiBridge
$bridge
Methods
__construct()
public
__construct(ApiBridge $bridge) : mixed
Parameters
- $bridge : ApiBridge
delete()
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
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>getCategoryRels()
Returns the mapping of a single category to a value per feed (category form).
public
getCategoryRels(int $categoryId) : array<int, array<string, mixed>>
Parameters
- $categoryId : int
Return values
array<int, array<string, mixed>>getParameterRels()
public
getParameterRels(int $feedId) : array<int, array<string, mixed>>
Parameters
- $feedId : int
Return values
array<int, array<string, mixed>>getParameterRelsForSet()
Returns the overrides of a single product set across all feeds ("Feeds" tab of the set).
public
getParameterRelsForSet(int $productSetId) : array<int, array<string, mixed>>
Parameters
- $productSetId : int
Return values
array<int, array<string, mixed>>getParameterTree()
public
getParameterTree(int $feedId) : array<int, array<string, mixed>>
Parameters
- $feedId : int
Return values
array<int, array<string, 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
ResultsaveCategoryRels()
Saves the category mapping. The delete is scoped to `category_id` only.
public
saveCategoryRels(int $categoryId, array<int, array<string, mixed>> $rows) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $categoryId : int
- $rows : array<int, array<string, mixed>>
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}saveParameterRels()
public
saveParameterRels(int $feedId, array<int, array<string, mixed>> $rows) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $feedId : int
- $rows : array<int, array<string, mixed>>
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}saveParameterRelsForSet()
Saves the overrides of one product set. The delete is scoped to `product_set_id` only.
public
saveParameterRelsForSet(int $productSetId, array<int, array<string, mixed>> $rows) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $productSetId : int
- $rows : array<int, array<string, mixed>>
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}saveParameterTree()
public
saveParameterTree(int $feedId, array<int, array<string, mixed>> $tree) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $feedId : int
- $tree : array<int, array<string, mixed>>
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}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
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
stringnormalizeResult()
private
normalizeResult(mixed $result) : array{success: bool, message: ?string, data: mixed, code: ?int}
Parameters
- $result : mixed
Return values
array{success: bool, message: ?string, data: mixed, code: ?int}normalizeRows()
Normalizes the untyped bridge payload to a list of rows with string keys.
private
normalizeRows(mixed $rows) : array<int, array<string, mixed>>
The bridge returns mixed (JSON or internal call), so the shape is verified here; the
mapper, service, manager and finally the forms then receive the declared list<array<string, mixed>>.
Parameters
- $rows : mixed