TariffFormTrait
Add and edit form of a company catalog tariff.
It has three parts:
- translated texts (name, title, description) as the owned
TariffTextcollection (derived identity), - the price matrix of
TariffPriceperpaymentRegionxpaymentGate, - express (SMS) prices of
TariffQuickPriceper region (premium SMS and similar).
Everything is saved by an object-graph save (owned collections with cascade). The region,
gate and currency FKs of prices are scalar (paymentRegionId, paymentGateId, currencyId).
The presenter supplies regions, gates and currencies ($this->tariffRegions, tariffGates,
tariffCurrencies).
Table of Contents
Methods
- createComponentEditForm() : Form
- addTariffMainFields() : void
- Main fields: credits, validity, activation and billing axes.
- addTariffPriceMatrix() : void
- Price matrix: a VAT rate select per region plus a price and an active flag for every region x gate combination.
- addTariffQuickPrices() : void
- Express (SMS) prices: a set of fields per region (premium SMS and similar).
- addTariffTranslationFields() : void
- Translated texts (name, title, description), active by the checkbox.
- buildCurrencyOptions() : array<int, string>
- Returns the currency options for the express price select (id to shortcut).
- buildTariffEntity() : Tariff
- buildTariffPrices() : ArrayCollection<int, TariffPrice>
- Builds the price matrix as the owned `TariffPrice` collection (scalar region, gate, currency).
- buildTariffQuickPrices() : ArrayCollection<int, TariffQuickPrice>
- Builds the express prices as the owned `TariffQuickPrice` collection (scalar region, currency from the select).
- getFormLanguages() : array<int, Language>
- Returns the languages for the translated fields (admin `LanguageManager`).
- saveTariffForm() : bool
- setTariffFormDefaults() : void
- str() : string
- strOrNull() : string|null
- tariffOffAxisPrices() : array<int, TariffPrice>
- Returns the price-list rows of the edited tariff that lie off the matrix axis.
- tariffOffAxisRowData() : array<int, array{regionId: int, gateId: int, currencyId: int, price: string, active: bool}>
- Returns the off-axis rows as data for the notice in the price list ({@see \App\Core\Traits\Admin\Presenters\TariffPriceMatrixTrait::buildTariffOffAxisRows()}).
Methods
createComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormaddTariffMainFields()
Main fields: credits, validity, activation and billing axes.
private
addTariffMainFields(Form $form) : void
Parameters
- $form : Form
addTariffPriceMatrix()
Price matrix: a VAT rate select per region plus a price and an active flag for every region x gate combination.
private
addTariffPriceMatrix(Form $form) : void
Parameters
- $form : Form
addTariffQuickPrices()
Express (SMS) prices: a set of fields per region (premium SMS and similar).
private
addTariffQuickPrices(Form $form) : void
Parameters
- $form : Form
addTariffTranslationFields()
Translated texts (name, title, description), active by the checkbox.
private
addTariffTranslationFields(Form $form) : void
Parameters
- $form : Form
buildCurrencyOptions()
Returns the currency options for the express price select (id to shortcut).
private
buildCurrencyOptions() : array<int, string>
Return values
array<int, string>buildTariffEntity()
private
buildTariffEntity(ArrayHash<string|int, mixed> $values) : Tariff
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
TariffbuildTariffPrices()
Builds the price matrix as the owned `TariffPrice` collection (scalar region, gate, currency).
private
buildTariffPrices(ArrayHash<string|int, mixed> $values) : ArrayCollection<int, TariffPrice>
Contract in TariffPriceMatrixTrait: the cell currency is the front-end axis (region rel of the gate, falling back to the region currency), a row exists only for a filled price (an empty cell means no row, clearing it deletes the row) and off-axis rows are carried over unchanged.
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
ArrayCollection<int, TariffPrice>buildTariffQuickPrices()
Builds the express prices as the owned `TariffQuickPrice` collection (scalar region, currency from the select).
private
buildTariffQuickPrices(ArrayHash<string|int, mixed> $values) : ArrayCollection<int, TariffQuickPrice>
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
ArrayCollection<int, TariffQuickPrice>getFormLanguages()
Returns the languages for the translated fields (admin `LanguageManager`).
private
getFormLanguages() : array<int, Language>
Return values
array<int, Language>saveTariffForm()
private
saveTariffForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
boolsetTariffFormDefaults()
private
setTariffFormDefaults(Form $form) : void
Parameters
- $form : Form
str()
private
str(mixed $value) : string
Parameters
- $value : mixed
Return values
stringstrOrNull()
private
strOrNull(mixed $value) : string|null
Parameters
- $value : mixed
Return values
string|nulltariffOffAxisPrices()
Returns the price-list rows of the edited tariff that lie off the matrix axis.
private
tariffOffAxisPrices() : array<int, TariffPrice>
Off-axis means another currency for a region x gate, or a region or gate outside the axes. The form does not edit them and saving carries them over unchanged, see TariffPriceMatrixTrait.
Return values
array<int, TariffPrice>tariffOffAxisRowData()
Returns the off-axis rows as data for the notice in the price list ({@see \App\Core\Traits\Admin\Presenters\TariffPriceMatrixTrait::buildTariffOffAxisRows()}).
private
tariffOffAxisRowData() : array<int, array{regionId: int, gateId: int, currencyId: int, price: string, active: bool}>