ApproxPriceLatteExtension
extends Extension
in package
Approximate price conversion into the website currency (`CurrencyContext::getCurrency()`).
{$price|approxPrice:$currency} renders e.g. "≈ €4,100" (with a translated "approximately"
for screen readers), or an empty string when the currencies match or the conversion is
impossible (ApproximatePrice::convert()). The original price is still rendered by
priceFormat; this filter only adds to it. A second argument true wraps the result in
parentheses preceded by a non-breaking space (advert list look), so in a template the filter
goes right after the original price, without a space.
currencyById($id) returns a currency from CurrencyContext::getCurrencies() by id (an
advert price currency is an entity-attribute-value parameter, the template only has its id).
Table of Contents
Constants
- TRANSLATION_KEY : mixed = 'front.general.price.approximately'
Properties
- $appContext : AppContext
- $priceFormatContext : PriceFormatContext
- $translator : ITranslator
- $unitFormatter : CurrencyUnitFormatter
Methods
- __construct() : mixed
- getFilters() : array<string|int, mixed>
- getFunctions() : array<string|int, mixed>
- currencyById() : object|null
- render() : Html|string
Constants
TRANSLATION_KEY
public
mixed
TRANSLATION_KEY
= 'front.general.price.approximately'
Properties
$appContext read-only
private
AppContext
$appContext
$priceFormatContext read-only
private
PriceFormatContext
$priceFormatContext
$translator read-only
private
ITranslator
$translator
$unitFormatter
private
CurrencyUnitFormatter
$unitFormatter
Methods
__construct()
public
__construct(AppContext $appContext, PriceFormatContext $priceFormatContext, ITranslator $translator) : mixed
Parameters
- $appContext : AppContext
- $priceFormatContext : PriceFormatContext
- $translator : ITranslator
getFilters()
public
getFilters() : array<string|int, mixed>
Return values
array<string|int, mixed>getFunctions()
public
getFunctions() : array<string|int, mixed>
Return values
array<string|int, mixed>currencyById()
private
currencyById(int|string|null $id) : object|null
Parameters
- $id : int|string|null
Return values
object|nullrender()
private
render(float|int|string|null $price, object|null $currency, bool $parentheses) : Html|string
Parameters
- $price : float|int|string|null
- $currency : object|null
- $parentheses : bool