CCrmRestProxyBase::internalizeFilterFields

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

	foreach($filter as $k => $v)
	{
		$operationInfo =  CSqlUtil::GetFilterOperation($k);
		$fieldName = $operationInfo['FIELD'];

		$info = $fieldsInfo[$fieldName] ?? null;
		if(!$info)
		{
			unset($filter[$k]);
			continue;
		}

		$operation = mb_substr($k, 0, mb_strlen($k) - mb_strlen($fieldName));
		if(isset($info['FORBIDDEN_FILTERS'])
			&& is_array($info['FORBIDDEN_FILTERS'])
			&& in_array($operation, $info['FORBIDDEN_FILTERS'], true))
		{
			unset($filter[$k]);
			continue;
		}

		$fieldType = $info['TYPE'] ?? '';
		if(($fieldType === 'crm_status' || $fieldType === 'crm_company' || $fieldType === 'crm_contact')
			&& ($operation === '%' || $operation === '%=' || $operation === '=%'))
		{
			//Prevent filtration by LIKE due to performance considerations
			$filter["={$fieldName}"] = $v;
			unset($filter[$k]);
			continue;
		}
		if (in_array($operation, ['<', '>', '>=', '<=']) && $fieldType === 'integer')
		{
			$filter[$k] = (int)$v;
		}

		if($fieldType === 'datetime')
		{
			$filter[$k] = CRestUtil::unConvertDateTime($v, true);
		}
		elseif($fieldType === 'date')
		{
			$filter[$k] = CRestUtil::unConvertDate($v);
		}
	}

	CCrmEntityHelper::PrepareMultiFieldFilter($filter, array(), '=%', true);
}

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