CCrmTimelineCommentRestProxy::innerGetList

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmTimelineCommentRestProxy
  4. innerGetList
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmTimelineCommentRestProxy
  • Вызов: CCrmTimelineCommentRestProxy::innerGetList
protected function innerGetList($order, $filter, $select, $navigation, &$errors)
{
	$entityId = (int)$filter['ENTITY_ID'];
	$entityTypeId = CCrmOwnerType::ResolveID(mb_strtoupper($filter['ENTITY_TYPE']));

	if (!Bitrix\Crm\Security\EntityAuthorization::checkReadPermission($entityTypeId, $entityId))
	{
		$errors[] = 'Access denied.';
		return false;
	}

	$params = [
		'filter' => [
			'TYPE_ID' => \Bitrix\Crm\Timeline\TimelineType::COMMENT,
			'BINDINGS.ENTITY_ID' => $entityId,
			'BINDINGS.ENTITY_TYPE_ID' => $entityTypeId,
		]
	];

	if (is_array($order))
	{
		$sortFields = [];
		foreach ($order as $fieldName => $direction)
		{
			if (in_array($fieldName, ['ID', 'CREATED', 'AUTHOR_ID'], true))
			{
				$sortFields[$fieldName] = ($direction === 'DESC') ? 'DESC' : 'ASC';
			}
		}
		if (!empty($sortFields))
		{
			$params['order'] = $sortFields;
		}
	}

	$page = isset($navigation['iNumPage']) ? (int)$navigation['iNumPage'] : 1;
	$limit = isset($navigation['nPageSize']) ? (int)$navigation['nPageSize'] : CCrmRestService::LIST_LIMIT;

	$dataRaw = \Bitrix\Crm\Timeline\Entity\TimelineTable::getList($params);
	$items = [];
	while($fields = $dataRaw->fetch())
	{
		$fields['ENTITY_ID'] = $entityId;
		$fields['ENTITY_TYPE'] = mb_strtolower(CCrmOwnerType::ResolveName($entityTypeId));
		$items[] = $this->prepareGetResult($fields, $select);
	}

	$dbResult = new CDBResult();
	$dbResult->InitFromArray($items);
	$dbResult->NavStart($limit, false, $page);
	return $dbResult;
}

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