ParameterFormTrait
Edit and add form of a top-level advert parameter, shared by Bazaar, Comcat and Eshop.
Covers the scalar settings (key, input type and search type, group, defaults, content filter
as ContentFilterMode, behavior flags, file limits) and the multilingual ParameterText
(name, labels, placeholders, search form labels and placeholders, messages, display_text).
Activation is a state toggle in the header. A new record is always a top-level parameter
(parentId = null, level = 1); lft/rgt are computed by the Api insert gate (the entity
implements TreeNodeInterface). Translations are an owned collection (object-graph cascade
through the Api hydrateForPersist).
The module Parameter and ParameterText entities are created and checked through
self::parameterEntityClass() and self::parameterTextEntityClass() (class-string
getters on AbstractParameterPresenter); the trait must not
import a module entity (same idiom as AbstractParameterRuleManager).
Table of Contents
Constants
- RESERVED_PARAMETER_KEYS : array<int, string> = ['search']
- Parameter keys reserved by the form layer; no parameter may use them, in any module.
Methods
- createComponentEditForm() : Form
- displayTargetColumn() : string
- Target column of display rules for a parameter (`cms_mod_{module}_parameters_parameter_id`).
- parameterEntityClass() : string
- parameterGroupManager() : Manager
- parameterManager() : Manager
- parameterTextEntityClass() : string
- supportsBlacklistedWords() : bool
- Whether visitors enter the parameter values, so blacklisted words apply (Bazaar, Comcat). E-shop values are entered only by the administrator, whom blacklisted words never restrict.
- supportsCoordinates() : bool
- Whether adverts of the module carry coordinates computed from the address (Bazaar, Comcat; not the e-shop).
- addBasicFields() : void
- Key, input types, group and default values.
- addBehaviorFields() : void
- Parameter behavior flags (checkboxes). "Always regenerate" (coordinates computed from the address on every save) only where adverts carry coordinates ({@see supportsCoordinates()}).
- addContentFilterFields() : void
- Content filter (replacement of URL and forbidden words), a three-state {@see ContentFilterMode}.
- addFileFields() : void
- Limits of uploaded files (relevant for the file and image types).
- addOptionsFields() : void
- Parameter options: the "has options" toggle in the Options tab.
- addSearchConsistencyRules() : void
- IMPORTANT: "in the default filter" without a search field type makes the parameter invisible.
- addTranslationFields() : void
- Multilingual parameter texts (one block of fields per language).
- collectParameterImageMeta() : array<string, mixed>
- Builds `$meta` for saving: a new icon (base64) and/or the delete flag.
- prepareContentFilterModeOptions() : array<int, string>
- Returns content filter options as `value => translation key` (off, onSave, onRender).
- prepareParameterGroupOptions() : array<int, NotTranslate>
- Returns parameter group options as `id => name` (current language, falls back to the first non-empty one).
- prepareTypeOptions() : array<int, NotTranslate>
- Returns parameter input types (ParameterType): key = constant, label = type name.
- saveParameterForm() : bool
- setParameterFormDefaults() : void
- translatedEntityName() : string
- Name of an entity with `translations` in the given language (falls back to the first non-empty one).
Constants
RESERVED_PARAMETER_KEYS
Parameter keys reserved by the form layer; no parameter may use them, in any module.
private
array<int, string>
RESERVED_PARAMETER_KEYS
= ['search']
search is the name of the fulltext field that the filter box adds above the parameter groups
(AdvertFilterBox::addFulltextField())
and that is written to the URL parameter search (fulltext) in the presenter.
The form does not collide today: parameter fields are named parameter_<id>
(ParameterFieldsTrait::parameterKey()), not by key.
But key is the name used to look a parameter up in code (EqualFilter('key', 'name')) and is
a likely future source of field names; a parameter named search would then silently override
the fulltext. A ban is cheaper than that trap.
compared in lowercase
Methods
createComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormdisplayTargetColumn()
Target column of display rules for a parameter (`cms_mod_{module}_parameters_parameter_id`).
protected
abstract displayTargetColumn() : string
Return values
stringparameterEntityClass()
protected
abstract parameterEntityClass() : string
Return values
stringparameterGroupManager()
protected
abstract parameterGroupManager() : Manager
Return values
ManagerparameterManager()
protected
abstract parameterManager() : Manager
Return values
ManagerparameterTextEntityClass()
protected
abstract parameterTextEntityClass() : string
Return values
stringsupportsBlacklistedWords()
Whether visitors enter the parameter values, so blacklisted words apply (Bazaar, Comcat). E-shop values are entered only by the administrator, whom blacklisted words never restrict.
protected
supportsBlacklistedWords() : bool
Return values
boolsupportsCoordinates()
Whether adverts of the module carry coordinates computed from the address (Bazaar, Comcat; not the e-shop).
protected
supportsCoordinates() : bool
Return values
booladdBasicFields()
Key, input types, group and default values.
private
addBasicFields(Form $form) : void
Parameters
- $form : Form
addBehaviorFields()
Parameter behavior flags (checkboxes). "Always regenerate" (coordinates computed from the address on every save) only where adverts carry coordinates ({@see supportsCoordinates()}).
private
addBehaviorFields(Form $form) : void
Parameters
- $form : Form
addContentFilterFields()
Content filter (replacement of URL and forbidden words), a three-state {@see ContentFilterMode}.
private
addContentFilterFields(Form $form) : void
Parameters
- $form : Form
addFileFields()
Limits of uploaded files (relevant for the file and image types).
private
addFileFields(Form $form) : void
Parameters
- $form : Form
addOptionsFields()
Parameter options: the "has options" toggle in the Options tab.
private
addOptionsFields(Form $form) : void
Parameters
- $form : Form
addSearchConsistencyRules()
IMPORTANT: "in the default filter" without a search field type makes the parameter invisible.
private
addSearchConsistencyRules(Form $form) : void
type (insert form) and searchType (search form) are two independent optional fields over the
same list ParameterType::TYPE_NAMES, so searchDefault = true with searchType = null
could be saved. AdvertFilterBox\LoadingTrait skips such a parameter (getSearchType() === null
means continue), so it silently never appears in the filter, with no error or message.
The rule forbids the contradictory state at save time, so it need not be traced back from an empty screen.
Parameters
- $form : Form
addTranslationFields()
Multilingual parameter texts (one block of fields per language).
private
addTranslationFields(Form $form) : void
Parameters
- $form : Form
collectParameterImageMeta()
Builds `$meta` for saving: a new icon (base64) and/or the delete flag.
private
collectParameterImageMeta(ArrayHash<string|int, mixed> $values) : array<string, mixed>
The Api creates the Asset (variants) and sets the scalar FK imageId (afterSave, processIcon), like Category.
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
array<string, mixed>prepareContentFilterModeOptions()
Returns content filter options as `value => translation key` (off, onSave, onRender).
private
prepareContentFilterModeOptions() : array<int, string>
Return values
array<int, string>prepareParameterGroupOptions()
Returns parameter group options as `id => name` (current language, falls back to the first non-empty one).
private
prepareParameterGroupOptions() : array<int, NotTranslate>
The name is final DB data, not a key, hence NotTranslate.
Return values
array<int, NotTranslate>prepareTypeOptions()
Returns parameter input types (ParameterType): key = constant, label = type name.
private
prepareTypeOptions() : array<int, NotTranslate>
The type names (Checkbox, Range Slider...) are technical names without a translation key,
hence NotTranslate; otherwise the form domain translator looks them up as keys.
Return values
array<int, NotTranslate>saveParameterForm()
private
saveParameterForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
boolsetParameterFormDefaults()
private
setParameterFormDefaults(Form $form) : void
Parameters
- $form : Form
translatedEntityName()
Name of an entity with `translations` in the given language (falls back to the first non-empty one).
private
translatedEntityName(object $entity, int|null $langId) : string
Parameters
- $entity : object
- $langId : int|null