CCrmRestProxyBase::tryInternalizeMultiFields

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmRestProxyBase
  4. tryInternalizeMultiFields
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmRestProxyBase
  • Вызов: CCrmRestProxyBase::tryInternalizeMultiFields
protected function tryInternalizeMultiFields(array &$fields, $fieldName, array &$data)
{
	if(!isset($fields[$fieldName]) && is_array($fields[$fieldName]))
	{
		return false;
	}

	$qty = 0;
	$result = array();
	$values = $fields[$fieldName];
	foreach($values as &$v)
	{
		$ID = $v['ID'] ?? 0;
		$value = isset($v['VALUE']) ? trim((string)$v['VALUE']) : '';
		//Allow empty values for persistent fields for support deletion operation.
		if($ID <= 0 && $value === '')
		{
			continue;
		}

		if($ID > 0 && isset($v['DELETE']) && mb_strtoupper((string)$v['DELETE']) === 'Y')
		{
			//Empty fields will be deleted.
			$value = '';
		}

		$valueType = isset($v['VALUE_TYPE']) ? trim((string)$v['VALUE_TYPE']) : '';
		if($valueType === '')
		{
			$valueType = CCrmFieldMulti::GetDefaultValueType($fieldName);
		}

		$key = $ID > 0 ? $ID : 'n'.(++$qty);
		$result[$key] = array('VALUE_TYPE' => $valueType, 'VALUE' => $value);
	}
	unset($v, $fields[$fieldName]);

	if(empty($result))
	{
		return false;
	}

	$data[$fieldName] = $result;
	return true;
}

Добавить комментарий