TariffFormTrait
Add/edit form of an advert tariff, in three parts: - multilingual texts (name, title, description): owned `TariffText` collection (derived identity), - price matrix: `TariffPrice` per `paymentRegion` x `paymentGate` (currency is the region currency), - express prices: `TariffQuickPrice` per region (premium SMS and similar).
Everything is saved through the object graph (owned collections plus cascade). The region, gateway and
currency FKs are scalar in the Bazaar prices (paymentRegionId, paymentGateId, currencyId). The
presenter supplies regions, gateways and currencies ($this->tariffRegions, tariffGates,
tariffCurrencies). See TariffFormTrait.
Table of Contents
Methods
- createComponentEditForm() : Form
- addTariffMainFields() : void
- Main fields: credits, validity, activation, billing axes.
- addTariffPriceMatrix() : void
- Price matrix: region VAT rate (select) plus price and active flag for each payment region x payment gateway combination.
- addTariffQuickPrices() : void
- Express prices: one set of fields per region (premium SMS and similar).
- addTariffTranslationFields() : void
- Multilingual texts (name, title, description), active per the language checkbox.
- buildCurrencyOptions() : array<int, string>
- Returns the currency options for the express price select (id mapped to shortcut).
- buildTariffEntity() : Tariff
- buildTariffPrices() : ArrayCollection<int, TariffPrice>
- Builds the owned `TariffPrice` collection from the price matrix (scalar region/gateway/currency).
- buildTariffQuickPrices() : ArrayCollection<int, TariffQuickPrice>
- Builds the owned `TariffQuickPrice` collection from the express prices (scalar region, currency from the select).
- getFormLanguages() : array<int, Language>
- Returns the languages for the multilingual 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 are off the matrix axis (another currency for a region x gateway, region or gateway outside the axes). The form does not edit them and saving carries them over unchanged, see {@see \App\Core\Traits\Admin\Presenters\TariffPriceMatrixTrait}.
- 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, billing axes.
private
addTariffMainFields(Form $form) : void
Parameters
- $form : Form
addTariffPriceMatrix()
Price matrix: region VAT rate (select) plus price and active flag for each payment region x payment gateway combination.
private
addTariffPriceMatrix(Form $form) : void
Parameters
- $form : Form
addTariffQuickPrices()
Express prices: one set of fields per region (premium SMS and similar).
private
addTariffQuickPrices(Form $form) : void
Parameters
- $form : Form
addTariffTranslationFields()
Multilingual texts (name, title, description), active per the language checkbox.
private
addTariffTranslationFields(Form $form) : void
Parameters
- $form : Form
buildCurrencyOptions()
Returns the currency options for the express price select (id mapped 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 owned `TariffPrice` collection from the price matrix (scalar region/gateway/currency).
private
buildTariffPrices(ArrayHash<string|int, mixed> $values) : ArrayCollection<int, TariffPrice>
Contract: see TariffPriceMatrixTrait. The cell currency is the front end axis (the gateway's region-rel, 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); off-axis rows are carried over unchanged.
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
ArrayCollection<int, TariffPrice>buildTariffQuickPrices()
Builds the owned `TariffQuickPrice` collection from the express prices (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 multilingual 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 are off the matrix axis (another currency for a region x gateway, region or gateway outside the axes). The form does not edit them and saving carries them over unchanged, see {@see \App\Core\Traits\Admin\Presenters\TariffPriceMatrixTrait}.
private
tariffOffAxisPrices() : array<int, TariffPrice>
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}>