CountryCodeDerivationTrait
ISO country code → derived free-text country on save.
The free-text country on master data (user, address book contact, company) is not dropped —
profile pages, checkout prefill, admin pickers and the invoice composer still read it. The form offers a country
select only; the text is derived here from the dictionary (Czech name by default).
- code set and known → code normalized (upper case) + text = country name,
- code empty → code null, text left untouched (a legacy text the backfill could not map is not wiped silently),
- code unknown → failure (the FK
*_country_code → cms_system_countrieswould fail the whole flush).
Use in beforeSave() of an Api manager.
Tags
Table of Contents
Methods
- deriveCountryText() : Result|null
Methods
deriveCountryText()
protected
deriveCountryText(string|null $countryCode, callable(Array): mixed $setCode, callable(string): mixed $setText[, int $textLength = 80 ]) : Result|null
Parameters
- $countryCode : string|null
- $setCode : callable(Array): mixed
- $setText : callable(string): mixed
- $textLength : int = 80