CCrmDealRecurringRestProxy::innerGet

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmDealRecurringRestProxy
  4. innerGet
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmDealRecurringRestProxy
  • Вызов: CCrmDealRecurringRestProxy::innerGet
protected function innerGet($ID, &$errors)
{
	$recurringInstance = \Bitrix\Crm\Recurring\Entity\Deal::getInstance();
	if (!$recurringInstance->isAllowedExpose())
	{
		$errors[] = 'Recurring is not allowed';
		return false;
	}

	$recurringDataRaw = $recurringInstance->getList([
		'filter' => ['ID' => (int)$ID],
		'limit' => 1
	]);

	$fields = $recurringDataRaw->fetch();

	$userPermissions = CCrmPerms::GetCurrentUserPermissions();
	if (empty($fields) || (int)$fields['DEAL_ID'] <= 0)
	{
		$errors[] = 'Recurring deal is not found.';
		return false;
	}
	$categoryID = CCrmDeal::GetCategoryID($fields['DEAL_ID']);
	if($categoryID < 0)
	{
		if (!CCrmDeal::CheckReadPermission(0, $userPermissions))
		{
			$errors[] =  'Access denied';
			return false;
		}
	}
	elseif(!CCrmDeal::CheckReadPermission($ID, CCrmPerms::GetCurrentUserPermissions(), $categoryID))
	{
		$errors[] = 'Access denied.';
		return false;
	}

	$result = array_intersect_key($fields, $this->getFieldsInfo());
	$params = $fields['PARAMS'];
	$formParamsMapper = \Bitrix\Crm\Recurring\Entity\Deal::getParameterMapper($params);
	$formParamsMapper->fillMap($params);
	$restParamsMapper = \Bitrix\Crm\Recurring\Entity\ParameterMapper\RestDeal::getInstance();
	$restParamsMapper->convert($formParamsMapper);
	$result['PARAMS'] = $restParamsMapper->getFormattedMap();
	return $result;
}

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