• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/rest/smile.php
  • Класс: BitrixMainRestSmile
  • Вызов: Smile::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 BitrixMainTypeDateTime)
			{
				$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 = self::getServerAddress().$value;
			}

			$key = str_replace('_', '', lcfirst(ucwords(mb_strtolower($key), '_')));

			$result[$key] = $value;
		}
		$data = $result;
	}

	return $data;
}