CCrmRestProxyBase::prepareListFromDbResult

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmRestProxyBase
  4. prepareListFromDbResult
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmRestProxyBase
  • Вызов: CCrmRestProxyBase::prepareListFromDbResult
protected function prepareListFromDbResult(CDBResult $dbResult, array $options)
{
	$result = array();
	$fieldsInfo = $this->getFieldsInfo();

	$selectedFmTypeIDs = $options['SELECTED_FM_TYPES'] ?? array();
	if(empty($selectedFmTypeIDs))
	{
		while($fields = $dbResult->Fetch())
		{
			$this->prepareListItemFields($fields);

			$this->externalizeFields($fields, $fieldsInfo);
			$result[] = $fields;
		}
	}
	else
	{
		$entityMap = array();
		while($fields = $dbResult->Fetch())
		{
			$this->prepareListItemFields($fields);

			$entityID = intval($this->getIdentity($fields));
			if($entityID <= 0)
			{
				throw new RestException('Could not find entity ID.');
			}
			$entityMap[$entityID] = $fields;
		}

		$this->prepareListItemMultiFields($entityMap, $this->getOwnerTypeID(), $selectedFmTypeIDs);

		foreach($entityMap as &$fields)
		{
			$this->externalizeFields($fields, $fieldsInfo);
			$result[] = $fields;
		}
		unset($fields);
	}

	return CCrmRestService::setNavData($result, $dbResult);
}

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