AddressFormat
class AddressFormat (View source)
Properties
protected Text | $text | ||
protected FormatterInterface | $formatter | ||
protected AddressFormatRepositoryInterface | $addressFormatRepository | ||
protected array | $options | Options that control the address formatting. |
Methods
Set the options that control how the address will be rendered. These can be passed to the underlying formatter class.
Formats a local concrete5 address lines array with the underlying address formatting library.
Gets an array of the used local address format keys, i.e. which address lines are used for the country.
Gets an array of the required local address format keys, i.e. which address lines are required for the country.
Converts the passed locale to the format expected by the underlying address formatting library.
Converts the underlying address format field array to the "local" format better understood within the concrete5 context.
Fetches the country's address format from the address format repository.
This is used only used when no country value is provided. Otherwise formatting is handled by the underlying address formatting library.
Details
__construct(Text $text)
The constructor for the service.
setOptions(array $options)
Set the options that control how the address will be rendered. These can be passed to the underlying formatter class.
string
format(array $addressData, string $format = 'html', string|null $locale = null)
Formats a local concrete5 address lines array with the underlying address formatting library.
The options that can be passed to the formatter in the array of the fourth argument:
- subdivision_names - Defines whether the subdivision names are printed to the output instead of their codes. Default: true.
- subdivision_translations - Defines whether the subdivision names are translated to the given locale if translations are available. Otherwise the will be printed out in their default locale. Default: true.
array
getCountryAddressUsedFields(string $code)
Gets an array of the used local address format keys, i.e. which address lines are used for the country.
array
getCountryAddressRequiredFields(string $code)
Gets an array of the required local address format keys, i.e. which address lines are required for the country.
protected string
convertLocale(string $locale)
Converts the passed locale to the format expected by the underlying address formatting library.
protected array
convertFormat(array $sourceFormat)
Converts the underlying address format field array to the "local" format better understood within the concrete5 context.
protected AddressFormat
getCountryAddressFormat(string $code)
Fetches the country's address format from the address format repository.
protected string
formatWithoutCountry(array $addressData, string $format = 'html')
This is used only used when no country value is provided. Otherwise formatting is handled by the underlying address formatting library.
Therefore, this does not have to care about the country specific formatting as there is no country information available.