CoolCMS API

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 and groupId straight from the Parameter entity
  • category-rel parameters: required is OR across categories, order is min, 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 over 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. IMPORTANT: only country and region (`level` <= 2): after importing municipalities into `cms_system_regions` (about 9.5k nodes) an unfiltered `findAll()` would flood the select. Choosing a municipality/district is left to the suggester, not this select.
getDefaultUserValues()  : array<int, mixed>
Pre-fills fields from the logged-in user for a new advert (edit has its own values from the entity). Dynamic parameters have no "default from user" in the code list, so the match is hard-wired via `Parameter::getKey()`; a key is mapped only when the form really contains a parameter with that key (otherwise skipped).
getRegionLabel()  : string
loadAdvertValues()  : array<int, mixed>
Returns edited advert values as parameterId => value | value[] | ['value','value2'].

Methods

getEntityValues()

protected getEntityValues() : array<int, mixed>
Return values
array<int, mixed>

loadParameterGroups()

protected loadParameterGroups() : array<string|int, mixed>
Return values
array<string|int, mixed>

aggregateCategoryParameterRels()

Aggregates CategoryParameterRels over 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. IMPORTANT: only country and region (`level` <= 2): after importing municipalities into `cms_system_regions` (about 9.5k nodes) an unfiltered `findAll()` would flood the select. Choosing a municipality/district is left to the suggester, not this select.

private buildRegionItems() : array<int, string>
Return values
array<int, string>

getDefaultUserValues()

Pre-fills fields from the logged-in user for a new advert (edit has its own values from the entity). Dynamic parameters have no "default from user" in the code list, so the match is hard-wired via `Parameter::getKey()`; a key is mapped only when the form really contains a parameter with that key (otherwise skipped).

private getDefaultUserValues() : array<int, mixed>

IMPORTANT: this branch hangs on getEntityValues() from this trait. A custom getEntityValues() in AdvertForm overrides the trait (a class method wins over a trait method) and the pre-fill silently disappears.

Return values
array<int, mixed>

loadAdvertValues()

Returns edited advert values as parameterId => value | value[] | ['value','value2'].

private loadAdvertValues() : array<int, mixed>

parameterId is read from the relation column, not 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.

Return values
array<int, mixed>
On this page

Search results