- Модуль: rest
- Путь к файлу: ~/bitrix/modules/rest/classes/general/rest_util.php
- Класс: CRestUtil
- Вызов: CRestUtil::processBatchElement
static function processBatchElement($query, $arResult, $keysCache = '')
{
$regexp = "/\$(".$keysCache.")([^s]*)/i";
if(preg_match_all($regexp, $query, $arMatches, PREG_SET_ORDER))
{
foreach($arMatches as $arMatch)
{
$path = $arMatch[2];
if(preg_match_all("/\[([^\]]+)\]/", $path, $arPath))
{
$r = $arResult[$arMatch[1]];
while(count($arPath[1]) > 0)
{
$key = array_shift($arPath[1]);
if(isset($r[$key]))
{
$r = $r[$key];
}
else
{
break;
}
}
if($arMatch[0] === $query)
{
$query = $r;
}
else
{
if (is_numeric($r))
{
$r = (string)$r;
}
if (!is_string($r))
{
continue;
}
$query = str_replace($arMatch[0], $r, $query);
}
}
}
}
return $query;
}