LoadingTrait
Loads parameters, parameter groups and extra items for selects (currency, region), plus pre-fill values from the edited Advert entity.
Returns ParameterFormItem[] with per-category resolved values:
- default parameters: order=lft, required + groupId straight from the Parameter entity
- category-rel parameters: required = OR across categories, order = MIN, groupId = the first category with a non-null groupId wins.
Table of Contents
Methods
- buildContext() : void
- getEntityValues() : array<int, mixed>
- loadParameterGroups() : array<string|int, mixed>
- loadParameters() : array<string|int, ParameterFormItem>
- aggregateCategoryParameterRels() : array<int, array{order: int, required: bool, groupId: ?int}>
- Aggregates CategoryParameterRels across all categories into a map parameterId => ['order' => MIN, 'required' => OR, 'groupId' => first-wins].
- buildCurrencyItems() : array<int, string>
- buildRegionItems() : array<int, string>
- Parameter SELECT_REGION: a plain `<select>`, not a Picker.
- getDefaultUserValues() : array<int, mixed>
- Pre-fills fields from the logged-in user for a new record (edit has its own values from the entity). Dynamic parameters have no "default from user" in the code list, so the mapping is hard-wired via `Parameter::getKey()`: a key is mapped only when the form really contains a parameter with that key (otherwise it is skipped).
- getRegionLabel() : string
- loadAdvertValues() : array<int, mixed>
- Values of the edited record: parameterId => value | value[] | ['value', 'value2'].
Methods
buildContext()
protected
buildContext() : void
getEntityValues()
protected
getEntityValues() : array<int, mixed>
Return values
array<int, mixed>loadParameterGroups()
protected
loadParameterGroups() : array<string|int, mixed>
Return values
array<string|int, mixed>loadParameters()
protected
loadParameters() : array<string|int, ParameterFormItem>
Return values
array<string|int, ParameterFormItem>aggregateCategoryParameterRels()
Aggregates CategoryParameterRels across all categories into a map parameterId => ['order' => MIN, 'required' => OR, 'groupId' => first-wins].
private
aggregateCategoryParameterRels(array<string|int, Category> $categories) : array<int, array{order: int, required: bool, groupId: ?int}>
Parameters
- $categories : array<string|int, Category>
Return values
array<int, array{order: int, required: bool, groupId: ?int}>buildCurrencyItems()
private
buildCurrencyItems() : array<int, string>
Return values
array<int, string>buildRegionItems()
Parameter SELECT_REGION: a plain `<select>`, not a Picker.
private
buildRegionItems() : array<int, string>
IMPORTANT: only country and region (level <= 2): after importing municipalities into
cms_system_regions (about 9,500 nodes) an unfiltered findAll() would flood the
select. Picking a municipality or district is up to the suggest, not this select.
Return values
array<int, string>getDefaultUserValues()
Pre-fills fields from the logged-in user for a new record (edit has its own values from the entity). Dynamic parameters have no "default from user" in the code list, so the mapping is hard-wired via `Parameter::getKey()`: a key is mapped only when the form really contains a parameter with that key (otherwise it is skipped).
private
getDefaultUserValues() : array<int, mixed>
IMPORTANT: this branch hangs on getEntityValues() from this trait. A custom
getEntityValues() returned in AdvertForm overrides the trait (a class method wins
over a trait method) and the pre-fill silently disappears.
Return values
array<int, mixed>getRegionLabel()
private
getRegionLabel(Region $region) : string
Parameters
- $region : Region
Return values
stringloadAdvertValues()
Values of the edited record: parameterId => value | value[] | ['value', 'value2'].
private
loadAdvertValues() : array<int, mixed>
parameterId is read from the relation column, not from getParameter()->getId(): the
association may not be loaded (the include parameterRels.parameter is up to the
caller) and without the column the whole row would be silently dropped.
getParameter() only looks up the type.