CoolCMS API

TariffFormTrait

Add/edit form of a message topping tariff, in three parts.

  • Multilingual texts (name/title/description): an owned TariffText collection (derived identity).
  • Price matrix: TariffPrice per paymentRegion and paymentGate (currency is the region currency).
  • Express prices: TariffQuickPrice per payment region (premium SMS and similar).

Everything is saved as an object graph (owned collections plus cascade): the region, gateway and currency are minimal managed references (new X()->setId()) that the Api hydrateForPersist resolves. The presenter supplies $this->tariffRegions, tariffGates and tariffCurrencies.

Table of Contents

Methods

createComponentEditForm()  : Form
addTariffMainFields()  : void
Adds the main fields: credits, validity, activation, billing axes.
addTariffPriceMatrix()  : void
Adds the price matrix: a VAT rate select per payment region, and a price plus active flag per region and gateway.
addTariffQuickPrices()  : void
Adds the express price fields, one set per payment region (premium SMS and similar).
addTariffTranslationFields()  : void
Adds the multilingual texts (name/title/description), required when the language checkbox is on.
buildCurrencyOptions()  : array<int, string>
Returns the currency options for the express price select (id => shortcut).
buildTariffEntity()  : Tariff
buildTariffPrices()  : ArrayCollection<int, TariffPrice>
Builds the price matrix as an owned `TariffPrice` collection (region, gateway and currency as managed references).
buildTariffQuickPrices()  : ArrayCollection<int, TariffQuickPrice>
Builds the express prices as an owned `TariffQuickPrice` collection (managed region reference, 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 rows of the edited tariff outside the matrix axis (another currency for a region and gateway, or a region/gateway outside the axes).
tariffOffAxisRowData()  : array<int, array{regionId: int, gateId: int, currencyId: int, price: string, active: bool}>
Returns the off-axis rows as data for the price list warning ({@see \App\Core\Traits\Admin\Presenters\TariffPriceMatrixTrait::buildTariffOffAxisRows()}).

Methods

addTariffMainFields()

Adds the main fields: credits, validity, activation, billing axes.

private addTariffMainFields(Form $form) : void
Parameters
$form : Form

addTariffPriceMatrix()

Adds the price matrix: a VAT rate select per payment region, and a price plus active flag per region and gateway.

private addTariffPriceMatrix(Form $form) : void
Parameters
$form : Form

addTariffQuickPrices()

Adds the express price fields, one set per payment region (premium SMS and similar).

private addTariffQuickPrices(Form $form) : void
Parameters
$form : Form

addTariffTranslationFields()

Adds the multilingual texts (name/title/description), required when the language checkbox is on.

private addTariffTranslationFields(Form $form) : void
Parameters
$form : Form

buildCurrencyOptions()

Returns the currency options for the express price select (id => 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
Tariff

buildTariffPrices()

Builds the price matrix as an owned `TariffPrice` collection (region, gateway and currency as managed references).

private buildTariffPrices(ArrayHash<string|int, mixed> $values) : ArrayCollection<int, TariffPrice>

Contract in TariffPriceMatrixTrait: the cell currency is the front-end axis (the gateway's region relation, 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 express prices as an owned `TariffQuickPrice` collection (managed region reference, 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
bool

str()

private str(mixed $value) : string
Parameters
$value : mixed
Return values
string

strOrNull()

private strOrNull(mixed $value) : string|null
Parameters
$value : mixed
Return values
string|null

tariffOffAxisPrices()

Returns the price rows of the edited tariff outside the matrix axis (another currency for a region and gateway, or a region/gateway outside the axes).

private tariffOffAxisPrices() : array<int, TariffPrice>

The form does not edit them and a save carries them over unchanged (TariffPriceMatrixTrait).

Return values
array<int, TariffPrice>

tariffOffAxisRowData()

Returns the off-axis rows as data for the price list warning ({@see \App\Core\Traits\Admin\Presenters\TariffPriceMatrixTrait::buildTariffOffAxisRows()}).

private tariffOffAxisRowData() : array<int, array{regionId: int, gateId: int, currencyId: int, price: string, active: bool}>
Return values
array<int, array{regionId: int, gateId: int, currencyId: int, price: string, active: bool}>
On this page

Search results