CoolCMS API

AdvertPriceStepsConfig
in package

FinalYes

Resolves the "price to" steps of the advert search box for the website currency.

The map currency key => steps comes from advert.bazaarPriceSteps in config/Shared/bazaar.neon (override in local.neon). A currency missing from the map gets the steps of the first configured currency, converted by the manual rate (ApproximatePrice) and rounded to 1 / 2 / 5 x 10^n. When conversion is impossible (rate 0, internal or unknown currency), the first currency's steps are returned together with its own currency, so the label never claims a currency the numbers are not in.

IMPORTANT: the price filter does not convert. A step goes into ?priceTo= as a plain number and is compared with the stored advert price regardless of its currency (AdvertListTrait), so a mismatched currency silently filters on the wrong amounts.

Table of Contents

Properties

$bazaarSteps  : array<string|int, mixed>

Methods

__construct()  : mixed
niceRound()  : int|float
Rounds to the nearest 1 / 2 / 5 x 10^n (41 becomes 50, 205 becomes 200, 4100 becomes 5000).
resolveBazaar()  : array{steps: list, currency: ?object}
normalize()  : array<int, int|float>

Properties

Methods

__construct()

public __construct([array<string, array<int, int|float>> $bazaarSteps = [] ]) : mixed
Parameters
$bazaarSteps : array<string, array<int, int|float>> = []

currency key (cms_system_currencies.key) => steps

niceRound()

Rounds to the nearest 1 / 2 / 5 x 10^n (41 becomes 50, 205 becomes 200, 4100 becomes 5000).

public static niceRound(float $value) : int|float
Parameters
$value : float
Return values
int|float

resolveBazaar()

public resolveBazaar(object|null $currency, iterable<string|int, object> $currencies) : array{steps: list, currency: ?object}
Parameters
$currency : object|null
$currencies : iterable<string|int, object>

available currencies (typically CurrencyContext::getCurrencies())

Return values
array{steps: list, currency: ?object} —

steps and the currency they are labeled in

normalize()

private static normalize(array<string|int, int|float|string> $steps) : array<int, int|float>
Parameters
$steps : array<string|int, int|float|string>
Return values
array<int, int|float> —

positive, deduplicated, ascending

On this page

Search results