- Модуль: currency
- Путь к файлу: ~/bitrix/modules/currency/lib/currencyclassifier.php
- Класс: BitrixCurrencyCurrencyClassifier
- Вызов: CurrencyClassifier::transform
static function transform(?string $b24Area, array $languageIds): void
{
if (self::$bitrix24Included === null)
{
self::$bitrix24Included = Loader::includeModule('bitrix24');
}
if (!self::$bitrix24Included)
{
return;
}
if ($b24Area === null || $b24Area === '')
{
$areaConfig = CBitrix24::getCurrentAreaConfig();
if (!empty($areaConfig))
{
$b24Area = $areaConfig['ID'];
}
unset($areaConfig);
}
if ($b24Area === null || $b24Area === '')
{
return;
}
if (!isset(self::$areaConfig[$b24Area]))
{
return;
}
$keys = [
'DEC_POINT' => true,
'THOUSANDS_VARIANT' => true,
'DECIMALS' => true
];
$config = self::$areaConfig[$b24Area];
$replaceRow = [];
$template = null;
if (!empty($config[self::MODIFIER_ALL]))
{
$replaceRow = array_intersect_key($config[self::MODIFIER_ALL], $keys);
if (isset($config[self::MODIFIER_ALL]['TEMPLATE']))
{
$template = $config[self::MODIFIER_ALL]['TEMPLATE'];
}
}
foreach (array_keys(self::$currencyClassifier) as $currency)
{
$currencyRow = $replaceRow;
$currencyTemplate = $template;
if (!empty($config[$currency]))
{
$currencyRow = array_merge(
$currencyRow,
array_intersect_key($config[$currency], $keys)
);
if (isset($config[$currency]['TEMPLATE']))
{
$currencyTemplate = $config[$currency]['TEMPLATE'];
}
}
if (!empty($currencyRow))
{
self::$currencyClassifier[$currency]['DEFAULT'] = array_merge(
self::$currencyClassifier[$currency]['DEFAULT'],
$currencyRow
);
}
if ($currencyTemplate !== null)
{
self::$currencyClassifier[$currency]['DEFAULT']['FORMAT_STRING'] = str_replace(
'#CURRENCY#',
trim(str_replace(
'#VALUE#',
'',
self::$currencyClassifier[$currency]['DEFAULT']['FORMAT_STRING']
)),
$currencyTemplate
);
}
if (!empty($currencyRow) || $currencyTemplate !== null)
{
foreach ($languageIds as $language)
{
if (!empty($currencyRow))
{
self::$currencyClassifier[$currency][$language] = array_merge(
self::$currencyClassifier[$currency][$language],
$currencyRow
);
}
if ($currencyTemplate !== null)
{
self::$currencyClassifier[$currency][$language]['FORMAT_STRING'] = str_replace(
'#CURRENCY#',
trim(str_replace(
'#VALUE#',
'',
self::$currencyClassifier[$currency][$language]['FORMAT_STRING']
)),
$currencyTemplate
);
}
}
}
}
}