- Модуль: imopenlines
- Путь к файлу: ~/bitrix/modules/imopenlines/lib/rest.php
- Класс: BitrixImOpenLinesRest
- Вызов: Rest::objectEncode
static function objectEncode($data, $options = [])
{
if (!is_array($options['IMAGE_FIELD']))
{
$options['IMAGE_FIELD'] = ['AVATAR', 'AVATAR_HR'];
}
if (is_array($data))
{
$result = [];
foreach ($data as $key => $value)
{
if (is_array($value))
{
$value = self::objectEncode($value, $options);
}
else if ($value instanceof DateTime)
{
$value = date('c', $value->getTimestamp());
}
else if (is_string($key) && in_array($key, $options['IMAGE_FIELD']) && is_string($value) && $value && mb_strpos($value, 'http') !== 0)
{
$value = Common::getServerAddress().$value;
}
$key = str_replace('_', '', lcfirst(ucwords(mb_strtolower($key), '_')));
$result[$key] = $value;
}
$data = $result;
}
return $data;
}