GiftFormTrait
Add/edit form of a gift: multilingual texts, validity, a double link to sets (`productSet` single picker, `offerSets` multi picker), cart value thresholds per currency ({@see GiftPrice}, like {@see VoucherFormTrait}: an upsert, not a time series) and visibility flags.
image (a gift with its own image when productSet is null) is not editable here: the value
is kept unchanged and the entity image FK stays as it was.
Table of Contents
Constants
- GIFT_DT_FORMAT : mixed = 'Y-m-d\TH:i'
- Value format of `<input type=datetime-local>`.
Methods
- createComponentEditForm() : Form
- addGiftBaseFields() : void
- addGiftOfferSetFields() : void
- M:N `offerSets`: a multiplier of rows with a Picker (like `ProductFormTrait::addProductCategoryFields()`).
- addGiftPriceFields() : void
- One row per currency (cart thresholds plus informative value) on the fixed axis {@see \App\UI\Admin\Eshop\Presenters\GiftPresenter::$giftCurrencies}.
- addGiftTranslationFields() : void
- Multilingual fields: one set per language (`<field>_<langId>`), active by checkbox.
- buildGiftEntity() : Gift
- buildGiftOfferSets() : ArrayCollection<int, ProductSet>
- M:N `offerSets` as light id references; Api `hydrateForPersist` finds them as managed entities and synchronizes the join table (like `ProductFormTrait::buildProductCategories()`).
- buildGiftPrices() : ArrayCollection<int, GiftPrice>
- Upserts the thresholds per currency; this is not a time series (same logic as `VoucherFormTrait::buildVoucherPrices()`).
- giftDecimalOrNull() : float|null
- loadGiftSelectData() : void
- Form axes (System currencies), loaded once per request; `CurrencyManager::findAll()` is not filtered to active.
- saveGiftForm() : bool
- setGiftFormDefaults() : void
Constants
GIFT_DT_FORMAT
Value format of `<input type=datetime-local>`.
private
mixed
GIFT_DT_FORMAT
= 'Y-m-d\TH:i'
Methods
createComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormaddGiftBaseFields()
private
addGiftBaseFields(Form $form) : void
Parameters
- $form : Form
addGiftOfferSetFields()
M:N `offerSets`: a multiplier of rows with a Picker (like `ProductFormTrait::addProductCategoryFields()`).
private
addGiftOfferSetFields(Form $form) : void
A row is a hidden productSetId plus a text label productSetName (rendered by the Picker).
Parameters
- $form : Form
addGiftPriceFields()
One row per currency (cart thresholds plus informative value) on the fixed axis {@see \App\UI\Admin\Eshop\Presenters\GiftPresenter::$giftCurrencies}.
private
addGiftPriceFields(Form $form) : void
Parameters
- $form : Form
addGiftTranslationFields()
Multilingual fields: one set per language (`<field>_<langId>`), active by checkbox.
private
addGiftTranslationFields(Form $form) : void
Parameters
- $form : Form
buildGiftEntity()
private
buildGiftEntity(ArrayHash<string|int, mixed> $values) : Gift
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
GiftbuildGiftOfferSets()
M:N `offerSets` as light id references; Api `hydrateForPersist` finds them as managed entities and synchronizes the join table (like `ProductFormTrait::buildProductCategories()`).
private
buildGiftOfferSets(ArrayHash<string|int, mixed> $values) : ArrayCollection<int, ProductSet>
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
ArrayCollection<int, ProductSet>buildGiftPrices()
Upserts the thresholds per currency; this is not a time series (same logic as `VoucherFormTrait::buildVoucherPrices()`).
private
buildGiftPrices(ArrayHash<string|int, mixed> $values, Gift $gift) : ArrayCollection<int, GiftPrice>
A currency without input is left out of the collection (owned orphanRemoval deletes the existing row).
Parameters
- $values : ArrayHash<string|int, mixed>
- $gift : Gift
Return values
ArrayCollection<int, GiftPrice>giftDecimalOrNull()
private
giftDecimalOrNull(string|null $value) : float|null
Parameters
- $value : string|null
Return values
float|nullloadGiftSelectData()
Form axes (System currencies), loaded once per request; `CurrencyManager::findAll()` is not filtered to active.
private
loadGiftSelectData() : void
saveGiftForm()
private
saveGiftForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
boolsetGiftFormDefaults()
private
setGiftFormDefaults(Form $form) : void
Parameters
- $form : Form