LocalizationFormTrait
Add/edit form of a localization.
The skeleton comes from BasePresenter::createForm(). The entity is flat.
languageId is a read-only scalar in the entity (insertable:false) duplicating the association, so
it is set through setLanguage() (managed reference by id), not as a scalar. regionId and
paymentRegionId are ordinary columns, so they are set as scalars.
IMPORTANT: the localization currency is not selected. The payment region of the localization
(DisplayRegionResolver) determines the currency and VAT of prices on the website, so the form
offers the payment region with its currency in the label.
Table of Contents
Methods
- createComponentEditForm() : Form
- buildLocalizationEntity() : Localization
- prepareFirstDayOfWeekOptions() : array<int, string>
- Returns weekdays by ISO-8601 (1 = Monday .. 7 = Sunday).
- prepareLanguageOptions() : array<int, string>
- preparePaymentRegionOptions() : array<int, string>
- Returns payment regions as "Name (currency)".
- prepareRegionOptions() : array<int, string>
- IMPORTANT: only countries (`level` 1). A localization pairs with a country, not a county, district or municipality, and after the municipality import into `cms_system_regions` (about 9.5k nodes) an unfiltered `findAll()` would flood the select.
- regionOptionLabel() : string
- Region name in the current language (falls back to the first non-empty name, then `#id`).
- saveLocalizationForm() : bool
- Saves the form data; the redirect is handled by {@see \App\Core\Base\Admin\BasePresenter::createForm()}.
- setLocalizationFormDefaults() : void
- tr() : string
- Translates a key in the form domain to a final string (fields with `setTranslator(null)`).
Methods
createComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormbuildLocalizationEntity()
private
buildLocalizationEntity(ArrayHash<string|int, mixed> $values) : Localization
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
LocalizationprepareFirstDayOfWeekOptions()
Returns weekdays by ISO-8601 (1 = Monday .. 7 = Sunday).
private
prepareFirstDayOfWeekOptions() : array<int, string>
The order is fixed and only labels change, so unlike other selects it is not sorted.
Return values
array<int, string>prepareLanguageOptions()
private
prepareLanguageOptions() : array<int, string>
Return values
array<int, string>preparePaymentRegionOptions()
Returns payment regions as "Name (currency)".
private
preparePaymentRegionOptions() : array<int, string>
The currency in the label is the one the website shows prices in for this localization. An inactive region is marked in the list so it is not picked by mistake.
Return values
array<int, string>prepareRegionOptions()
IMPORTANT: only countries (`level` 1). A localization pairs with a country, not a county, district or municipality, and after the municipality import into `cms_system_regions` (about 9.5k nodes) an unfiltered `findAll()` would flood the select.
private
prepareRegionOptions() : array<int, string>
Return values
array<int, string>regionOptionLabel()
Region name in the current language (falls back to the first non-empty name, then `#id`).
private
regionOptionLabel(Region $region, int|null $currentLang) : string
Parameters
- $region : Region
- $currentLang : int|null
Return values
stringsaveLocalizationForm()
Saves the form data; the redirect is handled by {@see \App\Core\Base\Admin\BasePresenter::createForm()}.
private
saveLocalizationForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
boolsetLocalizationFormDefaults()
private
setLocalizationFormDefaults(Form $form) : void
Parameters
- $form : Form
tr()
Translates a key in the form domain to a final string (fields with `setTranslator(null)`).
private
tr(string $key) : string
Parameters
- $key : string