AdvertForm
extends ParameterForm
in package
uses
LoadingTrait, FormFieldsTrait, BuildAdvertTrait, UploaderTrait, RegionSuggestHostTrait
Abstract component for a modular form built from parameters.
A child component supplies:
- loadParameters() and loadParameterGroups(): data from its own managers
- buildContext(): fills items for special selects (currency, region, comcat)
- getMode(): form or search (form by default)
- processSubmit(): saving or submitting the values (runs before the $onSuccess callbacks)
- optionally getEntityValues(): prefill from an entity
- optionally beforeSubmitButton(): custom fields before the submit button
- optionally buildRegistry(): custom handlers
Table of Contents
Constants
- ADVERT_PASSWORD_MIN_LENGTH : mixed = 6
- Minimum length of a custom edit password of an advert.
- REGION_PREVIEW_KEYS : array<string|int, mixed> = ['city', 'zip', 'country']
- Parameters that the preview prefills after a selection (parameter key = item data key).
Properties
- $container : Container
- $onError : array<string|int, callable(Form, static): void>
- Signature: function(Form $form, self $component): void
- $onSuccess : array<string|int, callable(Form, ArrayHash, static): void>
- $onValidate : array<string|int, callable(Form, ArrayHash, static): void>
- Events for the consumer (presenter / parent control). `ParameterForm` only renders and validates; business logic (save, email, redirect) belongs to whoever instantiates the component.
- $routerDispatcher : RouterDispatcher
- $translator : ITranslator
- $appContext : AppContext
- $componentParameters : array<string, mixed>
- $context : ParameterFormContext
- $currencyContext : CurrencyContext|null
- $deviceDetector : DeviceDetector|null
- $itemsByGroups : array<int, array<int, ParameterFormItem>>
- $languageContext : LanguageContext|null
- $localizationContext : LocalizationContext|null
- $parameterAndOptionList : array<int, ParameterInterface>
- $parameterGroupList : array<int, ParameterGroupInterface>
- $parameterItems : array<int, ParameterFormItem>
- $registry : ParameterHandlerRegistry
- $settingContext : SettingContext
- $themeContext : ThemeContext|null
- $translatorDomain : string|null
- Translation domain is set by the module subclass (`AdvertForm`, `AdvertFilterBox`, ...).
- $advert : Advert|null
- $advertManager : AdvertManager
- $blacklistedWordManager : BlacklistedWordManager
- $categoryList : array<string|int, Category>
- $categoryParameterRelManager : CategoryParameterRelManager
- $currencyManager : CurrencyManager
- $fieldBuilder : ParameterFieldBuilder|null
- $parameterGroupManager : ParameterGroupManager
- $parameterManager : ParameterManager
- $parametersInitialized : bool
- $regionManager : RegionManager
- $regionSuggestFactory : RegionSuggestFactory
- $uploaderDropzoneFactory : UploaderDropzoneFactory
- $userManager : UserManager
Methods
- __call() : mixed
- Dispatches `renderXyz()` to `render('Xyz', ...$args)`.
- __construct() : mixed
- buildAdvert() : Advert
- Builds the Advert entity from submitted values. Public: the consumer (or {@see \App\UI\Front\Comcat\Components\AdvertFormComponent\AdvertForm::processSubmit()}) uses it to get a fully prepared entity without persistence.
- createComponent() : IComponent|null
-
getActiveFilters()
: array<int, array{parameterId: int, parameter: string, label: string, remove: array
|null}> - Returns active filters for the badges above the list (`.pactive`), one entry per cancelable value, so "Sony" and "Canon" are two badges, not one.
- getAdvert() : Advert|null
- getAppContext() : AppContext
- getComponentParameter() : mixed
- Returns a component parameter, or null when it is not set.
- getContainer() : Container
- getCurrencyContext() : CurrencyContext|null
- getGroupChosenCount() : int
- Returns how many options of a group are selected, shown as a badge on the collapsible heading (`.filter-box__chosen`) so a collapsed group still shows that it filters.
- getLanguageContext() : LanguageContext|null
- getLocalizationContext() : LocalizationContext|null
- getRouterDispatcher() : RouterDispatcher
- getSettingContext() : SettingContext
- getSettings() : array<int, array<string, mixed>>
- getThemeContext() : ThemeContext|null
- getUploaderControlMap() : array<string|int, mixed>
- Overrides the parent {@see \App\UI\Front\Base\Components\ParameterFormComponent\ParameterForm::getUploaderControlMap()}: maps the first IMAGE_UPLOADER to the shared `imgUploader` and the first FILE_UPLOADER to `fileUploader`.
- getUploaderParameterIds() : array<string|int, int>
- Ids of parameters that have a dropzone uploader. A child may override it for different behavior (for example no uploaders: an empty array).
- hasServiceByType() : bool
- Returns whether the container has a service of the given type.
- initializeAllContexts() : void
- injectDeviceDetector() : void
- onCreate() : void
- render() : void
- renderActiveFilters() : void
- Renders badges of active filters above the list, not inside the filter: otherwise canceling a filter would be reachable only by scrolling back up.
- renderJs() : void
- setAdvert() : self
- setAppContext() : $this
- setCategoryList() : self
- setComponentParameter() : void
- Sets a component parameter.
- setCurrencyContext() : $this
- setLanguageContext() : $this
- setLocalizationContext() : $this
- setSettingContext() : $this
- setThemeContext() : $this
- setup() : void
- setupAppContext() : void
- typedComponent() : T
- Returns a subcomponent with a verified type.
- uploaderName() : string
- Name of the child uploader component for an upload parameter.
- beforeRender() : void
- Hook: a child component may add its own template variables (for example the edited entity).
- beforeSubmitButton() : void
- buildContext() : void
- buildRegistry() : ParameterHandlerRegistry
- Default registry covering all `ParameterType` constants. A child component may override it to add its own handlers (for example module-specific types).
- createComponentFileUploader() : UploaderDropzone
- createComponentForm() : Form
- createComponentImgUploader() : UploaderDropzone
- createComponentRegionSuggest() : Multiplier<string|int, RegionSuggest>
- extractParameterValues() : array<int, array<int, array{value: mixed, value2?: ?string}>>
- Helper that extracts form values. Returns only persistable parameters, i.e. not file/image types.
- findParameterByKey() : ParameterInterface|null
- frontPresenter() : BasePresenter|null
- Returns the front presenter the component is attached to (null outside the front end or when detached).
- getEntityValues() : array<int, mixed>
- getFieldBuilder() : ParameterFieldBuilder
- Lazy shared builder of parameter fields, initialized from the resolved engine state (items/groups/context/mode). Entity values are read at the first build (after `setAdvert()`/`setCategoryList()`), as with {@see \App\Core\Form\Parameters\Building\DefaultsTrait::applyDefaults()}.
- getMode() : string
- Hook: mode that selects `getType` or `getSearchType` on a parameter.
- getParameterTranslation() : ParameterTextInterface|null
- getSubmitLabel() : string
- Hook: translation key of the submit button caption.
- getTranslator() : ITranslator
- hasResolvedType() : bool
- For a child component: tells whether the form contains a parameter of the given type (respecting the mode via `resolveType()`).
- initParameters() : void
- isUploadParameter() : bool
- A classic `IMAGE` / `FILE` parameter has its own `<input type="file">` (via the handler); the dropzone uploader handles only the multi-upload `*_UPLOADER` variants.
- loadParameterGroups() : array<string|int, mixed>
- loadParameters() : array<string|int, ParameterFormItem>
- parameterKey() : string
- Form control key of a parameter (`parameter_<id>`). Field building is done by the shared {@see \App\Core\Form\Parameters\ParameterFieldBuilder}, but the engine and its consumers (filter URL params, email/region denormalization) need the same key to look up submitted values.
- processSubmit() : void
- resolveDefaultValue() : string|null
- resolveType() : int|null
- setTemplateFile() : void
- setTranslator() : self
- usesDefaultParameters() : bool
- Hook: when a child component returns true, only parameters with `getDefault()` = true (classic) or `getSearchDefault()` = true (search) are shown.
- 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].
- applyParameterRels() : void
- Builds the object-graph collection `parameterRels` from the submitted rows. `parameter` is a light reference (`new Parameter()->setId($id)`) that `EntityHydrator::extract` serializes as `{"id":{"id":X}}` and the Api `hydrateForPersist` resolves as a managed entity.
- buildCurrencyItems() : array<int, string>
- buildParameterAndOptionList() : void
- Returns ids of the parameters that this parameterId uses (directly or through options), for lookup from rules. Options have no per-category override, so they are read straight from the Parameter entity.
- buildRegionItems() : array<int, string>
- Parameter SELECT_REGION: a plain `<select>`, not a Picker.
- buildRegionPreviewFieldMap() : array<string, string>
- configureUploaders() : void
- createMultiplierComponent() : Multiplier<string|int, IComponent>
- Creates a multiplier for the component.
- createNewComponentInstance() : IComponent|null
- Creates a new component instance without adding it to the presenter; used by the multiplier.
- createStandardComponent() : IComponent|null
- Creates a standard component (not a multiplier).
- findFirstParameterOfType() : Parameter|null
- gateAdvertColumns() : void
- Column gate of the contact e-mail parameter: it is written into the profile column `email` varchar(255) ({@see BuildAdvertTrait}). The parameter builder knows only the parameter type, so a longer value failed the whole save on the database with the generic "could not be saved" message instead of an error at the field.
- 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
- indexById() : array<int, T>
- indexItemsByGroups() : void
- indexItemsById() : array<int, ParameterFormItem>
- initRegionPickerContext() : void
- Selection validator for {@see ParameterFormContext::$regionValidator}: the advert form accepts only an active municipality (tree leaf), so an old advert filed under a country forces choosing a municipality on edit.
- loadAdvertValues() : array<int, mixed>
- Values of the edited record: parameterId => value | value[] | ['value', 'value2'].
- parameterControl() : BaseControl|null
- Form control of the parameter with the given key, null when the category does not use it.
- parseFileTypes() : array<string|int, string>
- prepareExistingAssets() : array<int, array<string, mixed>>
- prepareExistingFiles() : array<int, array<string, mixed>>
- setExpirationDate() : void
Constants
ADVERT_PASSWORD_MIN_LENGTH
Minimum length of a custom edit password of an advert.
private
mixed
ADVERT_PASSWORD_MIN_LENGTH
= 6
REGION_PREVIEW_KEYS
Parameters that the preview prefills after a selection (parameter key = item data key).
private
array<string|int, mixed>
REGION_PREVIEW_KEYS
= ['city', 'zip', 'country']
Properties
$container
public
Container
$container
Attributes
- #[Inject]
$onError
Signature: function(Form $form, self $component): void
public
array<string|int, callable(Form, static): void>
$onError
= []
$onSuccess
public
array<string|int, callable(Form, ArrayHash, static): void>
$onSuccess
= []
$onValidate
Events for the consumer (presenter / parent control). `ParameterForm` only renders and validates; business logic (save, email, redirect) belongs to whoever instantiates the component.
public
array<string|int, callable(Form, ArrayHash, static): void>
$onValidate
= []
Signature: function(Form $form, ArrayHash $values, self $component): void
$routerDispatcher
public
RouterDispatcher
$routerDispatcher
$translator
public
ITranslator
$translator
Tags
$appContext
protected
AppContext
$appContext
$componentParameters
protected
array<string, mixed>
$componentParameters
= []
component parameters set by setComponentParameter()
$context
protected
ParameterFormContext
$context
$currencyContext
protected
CurrencyContext|null
$currencyContext
= NULL
$deviceDetector
protected
DeviceDetector|null
$deviceDetector
= NULL
$itemsByGroups
protected
array<int, array<int, ParameterFormItem>>
$itemsByGroups
= []
items grouped by the resolved groupId
$languageContext
protected
LanguageContext|null
$languageContext
= NULL
$localizationContext
protected
LocalizationContext|null
$localizationContext
= NULL
$parameterAndOptionList
protected
array<int, ParameterInterface>
$parameterAndOptionList
= []
parameters together with their options (for lookup from rules)
$parameterGroupList
protected
array<int, ParameterGroupInterface>
$parameterGroupList
= []
indexed by id
$parameterItems
protected
array<int, ParameterFormItem>
$parameterItems
= []
indexed by parameterId, with values resolved per form (order/required/groupId)
$registry
protected
ParameterHandlerRegistry
$registry
$settingContext
protected
SettingContext
$settingContext
$themeContext
protected
ThemeContext|null
$themeContext
= NULL
$translatorDomain
Translation domain is set by the module subclass (`AdvertForm`, `AdvertFilterBox`, ...).
protected
string|null
$translatorDomain
= 'front.comcat.components.advertForm'
$advert
private
Advert|null
$advert
= null
$advertManager read-only
private
AdvertManager
$advertManager
$blacklistedWordManager read-only
private
BlacklistedWordManager
$blacklistedWordManager
$categoryList
private
array<string|int, Category>
$categoryList
= []
$categoryParameterRelManager read-only
private
CategoryParameterRelManager
$categoryParameterRelManager
$currencyManager read-only
private
CurrencyManager
$currencyManager
$fieldBuilder
private
ParameterFieldBuilder|null
$fieldBuilder
= null
$parameterGroupManager read-only
private
ParameterGroupManager
$parameterGroupManager
$parameterManager read-only
private
ParameterManager
$parameterManager
$parametersInitialized
private
bool
$parametersInitialized
= false
$regionManager read-only
private
RegionManager
$regionManager
$regionSuggestFactory read-only
private
RegionSuggestFactory
$regionSuggestFactory
$uploaderDropzoneFactory read-only
private
UploaderDropzoneFactory
$uploaderDropzoneFactory
$userManager read-only
private
UserManager
$userManager
Methods
__call()
Dispatches `renderXyz()` to `render('Xyz', ...$args)`.
public
__call(string $name, array<string|int, mixed> $args) : mixed
Called only when the component has no renderXyz() method of its own.
Parameters
- $name : string
- $args : array<string|int, mixed>
__construct()
public
__construct(AdvertManager $advertManager, ParameterManager $parameterManager, ParameterGroupManager $parameterGroupManager, CurrencyManager $currencyManager, RegionManager $regionManager, UploaderDropzoneFactory $uploaderDropzoneFactory, UserManager $userManager, CategoryParameterRelManager $categoryParameterRelManager, BlacklistedWordManager $blacklistedWordManager, RegionSuggestFactory $regionSuggestFactory) : mixed
Parameters
- $advertManager : AdvertManager
- $parameterManager : ParameterManager
- $parameterGroupManager : ParameterGroupManager
- $currencyManager : CurrencyManager
- $regionManager : RegionManager
- $uploaderDropzoneFactory : UploaderDropzoneFactory
- $userManager : UserManager
- $categoryParameterRelManager : CategoryParameterRelManager
- $blacklistedWordManager : BlacklistedWordManager
- $regionSuggestFactory : RegionSuggestFactory
buildAdvert()
Builds the Advert entity from submitted values. Public: the consumer (or {@see \App\UI\Front\Comcat\Components\AdvertFormComponent\AdvertForm::processSubmit()}) uses it to get a fully prepared entity without persistence.
public
buildAdvert(ArrayHash $values[, string|null $passwordHash = null ]) : Advert
Parameters
- $values : ArrayHash
- $passwordHash : string|null = null
Return values
AdvertcreateComponent()
public
createComponent(string $name) : IComponent|null
Parameters
- $name : string
Return values
IComponent|nullgetActiveFilters()
Returns active filters for the badges above the list (`.pactive`), one entry per cancelable value, so "Sony" and "Canon" are two badges, not one.
public
getActiveFilters() : array<int, array{parameterId: int, parameter: string, label: string, remove: array|null}>
Read from request parameters (p[<parameterId>]) and from already loaded parameter entities
(optionsCollection is in the filter includes), so it costs no extra query.
remove is the p value without that one option; the template turns it into a link via {plink}.
When nothing remains after removal it is null and the link leads to the list without a filter.
Return values
array<int, array{parameterId: int, parameter: string, label: string, remove: arraygetAdvert()
public
getAdvert() : Advert|null
Return values
Advert|nullgetAppContext()
public
getAppContext() : AppContext
Return values
AppContextgetComponentParameter()
Returns a component parameter, or null when it is not set.
public
getComponentParameter(string $name) : mixed
Parameters
- $name : string
getContainer()
public
getContainer() : Container
Return values
ContainergetCurrencyContext()
public
getCurrencyContext() : CurrencyContext|null
Return values
CurrencyContext|nullgetGroupChosenCount()
Returns how many options of a group are selected, shown as a badge on the collapsible heading (`.filter-box__chosen`) so a collapsed group still shows that it filters.
public
getGroupChosenCount(ControlGroup $group) : int
Counted from the form values, i.e. request parameters, so it costs no extra query. A multi-value field (CheckboxList/MultiSelect) counts per item, a single-value one as 1. Buttons and hidden fields are skipped: they are not user choices.
Lives on the shared base because Style_Filter.latte serves the e-shop, advert and company
catalog filters, so every child gets it at once.
Parameters
- $group : ControlGroup
Return values
intgetLanguageContext()
public
getLanguageContext() : LanguageContext|null
Return values
LanguageContext|nullgetLocalizationContext()
public
getLocalizationContext() : LocalizationContext|null
Return values
LocalizationContext|nullgetRouterDispatcher()
public
getRouterDispatcher() : RouterDispatcher
Return values
RouterDispatchergetSettingContext()
public
getSettingContext() : SettingContext
Return values
SettingContextgetSettings()
public
getSettings() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>getThemeContext()
public
getThemeContext() : ThemeContext|null
Return values
ThemeContext|nullgetUploaderControlMap()
Overrides the parent {@see \App\UI\Front\Base\Components\ParameterFormComponent\ParameterForm::getUploaderControlMap()}: maps the first IMAGE_UPLOADER to the shared `imgUploader` and the first FILE_UPLOADER to `fileUploader`.
public
getUploaderControlMap() : array<string|int, mixed>
Other parameters of the same type get a classic input (no dropzone).
Return values
array<string|int, mixed>getUploaderParameterIds()
Ids of parameters that have a dropzone uploader. A child may override it for different behavior (for example no uploaders: an empty array).
public
getUploaderParameterIds() : array<string|int, int>
Return values
array<string|int, int>hasServiceByType()
Returns whether the container has a service of the given type.
public
hasServiceByType(string $className) : bool
The name is composed dynamically (module plus component), so class_exists() runs first, and
a true result guarantees a valid type.
Parameters
- $className : string
Tags
Return values
boolinitializeAllContexts()
public
initializeAllContexts() : void
injectDeviceDetector()
public
injectDeviceDetector(DeviceDetector $detector) : void
Parameters
- $detector : DeviceDetector
onCreate()
public
onCreate() : void
render()
public
render([string $style = 'Style_1' ]) : void
Parameters
- $style : string = 'Style_1'
renderActiveFilters()
Renders badges of active filters above the list, not inside the filter: otherwise canceling a filter would be reachable only by scrolling back up.
public
renderActiveFilters() : void
Called from the list template as {control filterBox:activeFilters}. Renders nothing at all
(not even an empty wrapper) when no filter is active.
renderJs()
public
renderJs() : void
setAdvert()
public
setAdvert(Advert|null $advert) : self
Parameters
- $advert : Advert|null
Return values
selfsetAppContext()
public
setAppContext(AppContext $appContext) : $this
Parameters
- $appContext : AppContext
Return values
$thissetCategoryList()
public
setCategoryList(array<string|int, Category> $categoryList) : self
Parameters
- $categoryList : array<string|int, Category>
Return values
selfsetComponentParameter()
Sets a component parameter.
public
setComponentParameter(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
setCurrencyContext()
public
setCurrencyContext(CurrencyContext|null $currencyContext) : $this
Parameters
- $currencyContext : CurrencyContext|null
Return values
$thissetLanguageContext()
public
setLanguageContext(LanguageContext|null $languageContext) : $this
Parameters
- $languageContext : LanguageContext|null
Return values
$thissetLocalizationContext()
public
setLocalizationContext(LocalizationContext|null $localizationContext) : $this
Parameters
- $localizationContext : LocalizationContext|null
Return values
$thissetSettingContext()
public
setSettingContext(SettingContext $settingContext) : $this
Parameters
- $settingContext : SettingContext
Return values
$thissetThemeContext()
public
setThemeContext(ThemeContext|null $themeContext) : $this
Parameters
- $themeContext : ThemeContext|null
Return values
$thissetup()
public
setup(BasePresenter|BasePresenter $presenter) : void
Parameters
- $presenter : BasePresenter|BasePresenter
setupAppContext()
public
setupAppContext(AppContext $appContext) : void
Parameters
- $appContext : AppContext
typedComponent()
Returns a subcomponent with a verified type.
public
typedComponent(string $name, T> $type) : T
Use it instead of an inline @var above $this['x'] (which does not narrow the type) and
instead of the generic IComponent that $this['x'] returns. See
Form::typedComponent().
Parameters
- $name : string
- $type : T>
Tags
Return values
TuploaderName()
Name of the child uploader component for an upload parameter.
public
uploaderName(ParameterInterface $parameter) : string
In Latte: {control "uploader_$parameterId"}.
Parameters
- $parameter : ParameterInterface
Return values
stringbeforeRender()
Hook: a child component may add its own template variables (for example the edited entity).
protected
beforeRender(string $style) : void
Parameters
- $style : string
beforeSubmitButton()
protected
beforeSubmitButton(Form $form) : void
Parameters
- $form : Form
buildContext()
protected
buildContext() : void
buildRegistry()
Default registry covering all `ParameterType` constants. A child component may override it to add its own handlers (for example module-specific types).
protected
buildRegistry() : ParameterHandlerRegistry
Return values
ParameterHandlerRegistrycreateComponentFileUploader()
protected
createComponentFileUploader() : UploaderDropzone
Return values
UploaderDropzonecreateComponentForm()
protected
createComponentForm() : Form
Return values
FormcreateComponentImgUploader()
protected
createComponentImgUploader() : UploaderDropzone
Return values
UploaderDropzonecreateComponentRegionSuggest()
protected
createComponentRegionSuggest() : Multiplier<string|int, RegionSuggest>
Return values
Multiplier<string|int, RegionSuggest>extractParameterValues()
Helper that extracts form values. Returns only persistable parameters, i.e. not file/image types.
protected
extractParameterValues(ArrayHash $values) : array<int, array<int, array{value: mixed, value2?: ?string}>>
The key is parameterId, the value a list of rows to persist; the handler decides (scalar: 1 row, multiselect: N rows, range: 1 row with value+value2).
Parameters
- $values : ArrayHash
Return values
array<int, array<int, array{value: mixed, value2?: ?string}>>findParameterByKey()
protected
findParameterByKey(string $key) : ParameterInterface|null
Parameters
- $key : string
Return values
ParameterInterface|nullfrontPresenter()
Returns the front presenter the component is attached to (null outside the front end or when detached).
protected
frontPresenter() : BasePresenter|null
Return values
BasePresenter|nullgetEntityValues()
protected
getEntityValues() : array<int, mixed>
Return values
array<int, mixed>getFieldBuilder()
Lazy shared builder of parameter fields, initialized from the resolved engine state (items/groups/context/mode). Entity values are read at the first build (after `setAdvert()`/`setCategoryList()`), as with {@see \App\Core\Form\Parameters\Building\DefaultsTrait::applyDefaults()}.
protected
getFieldBuilder() : ParameterFieldBuilder
Return values
ParameterFieldBuildergetMode()
Hook: mode that selects `getType` or `getSearchType` on a parameter.
protected
getMode() : string
Form by default (advert/insert); search forms return MODE_SEARCH.
Return values
stringgetParameterTranslation()
protected
getParameterTranslation(ParameterInterface $parameter) : ParameterTextInterface|null
Parameters
- $parameter : ParameterInterface
Return values
ParameterTextInterface|nullgetSubmitLabel()
Hook: translation key of the submit button caption.
protected
getSubmitLabel() : string
Return values
stringgetTranslator()
protected
getTranslator() : ITranslator
Return values
ITranslatorhasResolvedType()
For a child component: tells whether the form contains a parameter of the given type (respecting the mode via `resolveType()`).
protected
hasResolvedType(int $type) : bool
Parameters
- $type : int
Return values
boolinitParameters()
protected
initParameters() : void
isUploadParameter()
A classic `IMAGE` / `FILE` parameter has its own `<input type="file">` (via the handler); the dropzone uploader handles only the multi-upload `*_UPLOADER` variants.
protected
isUploadParameter(ParameterInterface $parameter) : bool
Parameters
- $parameter : ParameterInterface
Return values
boolloadParameterGroups()
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>parameterKey()
Form control key of a parameter (`parameter_<id>`). Field building is done by the shared {@see \App\Core\Form\Parameters\ParameterFieldBuilder}, but the engine and its consumers (filter URL params, email/region denormalization) need the same key to look up submitted values.
protected
parameterKey(ParameterInterface $parameter) : string
Parameters
- $parameter : ParameterInterface
Return values
stringprocessSubmit()
protected
processSubmit(Form $form, ArrayHash $values) : void
Parameters
- $form : Form
- $values : ArrayHash
resolveDefaultValue()
protected
resolveDefaultValue(ParameterInterface $parameter) : string|null
Parameters
- $parameter : ParameterInterface
Return values
string|nullresolveType()
protected
resolveType(ParameterInterface $parameter) : int|null
Parameters
- $parameter : ParameterInterface
Return values
int|nullsetTemplateFile()
protected
setTemplateFile(string $dir, string $filename) : void
Parameters
- $dir : string
- $filename : string
setTranslator()
protected
setTranslator(ITranslator $translator) : self
Parameters
- $translator : ITranslator
Return values
selfusesDefaultParameters()
Hook: when a child component returns true, only parameters with `getDefault()` = true (classic) or `getSearchDefault()` = true (search) are shown.
protected
usesDefaultParameters() : bool
Return values
boolaggregateCategoryParameterRels()
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}>applyParameterRels()
Builds the object-graph collection `parameterRels` from the submitted rows. `parameter` is a light reference (`new Parameter()->setId($id)`) that `EntityHydrator::extract` serializes as `{"id":{"id":X}}` and the Api `hydrateForPersist` resolves as a managed entity.
private
applyParameterRels(Advert $advert, array<int, array{id: int, value: string, value2?: string}> $rows) : void
IMPORTANT: call only when $rows !== []. Replacing the collection with an empty array
would make orphanRemoval on the Api side delete all existing parameters of the advert.
An empty submit leaves the collection untouched (the clone carries the old state).
Parameters
- $advert : Advert
- $rows : array<int, array{id: int, value: string, value2?: string}>
buildCurrencyItems()
private
buildCurrencyItems() : array<int, string>
Return values
array<int, string>buildParameterAndOptionList()
Returns ids of the parameters that this parameterId uses (directly or through options), for lookup from rules. Options have no per-category override, so they are read straight from the Parameter entity.
private
buildParameterAndOptionList() : void
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>buildRegionPreviewFieldMap()
private
buildRegionPreviewFieldMap() : array<string, string>
Return values
array<string, string> —data key => form control name of the parameter
configureUploaders()
private
configureUploaders() : void
createMultiplierComponent()
Creates a multiplier for the component.
private
createMultiplierComponent(string $name) : Multiplier<string|int, IComponent>
Parameters
- $name : string
Return values
Multiplier<string|int, IComponent>createNewComponentInstance()
Creates a new component instance without adding it to the presenter; used by the multiplier.
private
createNewComponentInstance(string $baseName[, int|string|null $uniqueKey = null ]) : IComponent|null
Parameters
- $baseName : string
- $uniqueKey : int|string|null = null
Return values
IComponent|nullcreateStandardComponent()
Creates a standard component (not a multiplier).
private
createStandardComponent(string $name) : IComponent|null
Parameters
- $name : string
Return values
IComponent|nullfindFirstParameterOfType()
private
findFirstParameterOfType(int $type) : Parameter|null
Parameters
- $type : int
Return values
Parameter|nullgateAdvertColumns()
Column gate of the contact e-mail parameter: it is written into the profile column `email` varchar(255) ({@see BuildAdvertTrait}). The parameter builder knows only the parameter type, so a longer value failed the whole save on the database with the generic "could not be saved" message instead of an error at the field.
private
gateAdvertColumns(Form $form) : void
Parameters
- $form : Form
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
stringindexById()
private
indexById(array<string|int, T> $items) : array<int, T>
Parameters
- $items : array<string|int, T>
Tags
Return values
array<int, T>indexItemsByGroups()
private
indexItemsByGroups() : void
indexItemsById()
private
indexItemsById(array<string|int, ParameterFormItem> $items) : array<int, ParameterFormItem>
Parameters
- $items : array<string|int, ParameterFormItem>
Return values
array<int, ParameterFormItem>initRegionPickerContext()
Selection validator for {@see ParameterFormContext::$regionValidator}: the advert form accepts only an active municipality (tree leaf), so an old advert filed under a country forces choosing a municipality on edit.
private
initRegionPickerContext() : void
loadAdvertValues()
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.
Return values
array<int, mixed>parameterControl()
Form control of the parameter with the given key, null when the category does not use it.
private
parameterControl(Form $form, string $key) : BaseControl|null
Parameters
- $form : Form
- $key : string
Return values
BaseControl|nullparseFileTypes()
private
parseFileTypes(string|null $fileType, array<string|int, string> $fallback) : array<string|int, string>
Parameters
- $fileType : string|null
- $fallback : array<string|int, string>
Return values
array<string|int, string>prepareExistingAssets()
private
prepareExistingAssets() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>prepareExistingFiles()
private
prepareExistingFiles() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>setExpirationDate()
private
setExpirationDate(Advert $advert) : void
Parameters
- $advert : Advert