CCrmEnumerationRestProxy::processMethodRequest

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmEnumerationRestProxy
  4. processMethodRequest
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmEnumerationRestProxy
  • Вызов: CCrmEnumerationRestProxy::processMethodRequest
public function processMethodRequest($name, $nameDetails, $arParams, $nav, $server)
{
	$descriptions = null;
	$codes = [];

	$name = mb_strtoupper($name);
	$nameSuffix = mb_strtoupper(!empty($nameDetails)? implode('_', $nameDetails) : '');
	if($name === 'SETTINGS')
	{
		if($nameSuffix === 'MODE')
		{
			$descriptions = \Bitrix\Crm\Settings\Mode::getAllDescriptions();
		}
	}
	elseif($name === 'OWNERTYPE')
	{
		$allDescriptions = CCrmOwnerType::GetAllDescriptions();
		$types = [
			CCrmOwnerType::Lead => CCrmOwnerType::Lead,
			CCrmOwnerType::Deal => CCrmOwnerType::Deal,
			CCrmOwnerType::Contact => CCrmOwnerType::Contact,
			CCrmOwnerType::Company => CCrmOwnerType::Company,
			CCrmOwnerType::Quote => CCrmOwnerType::Quote,
			CCrmOwnerType::Invoice => CCrmOwnerType::Invoice,
			CCrmOwnerType::Requisite => CCrmOwnerType::Requisite,
		];
		foreach ($allDescriptions as $entityTypeId => $description)
		{
			if (isset($types[$entityTypeId]) || \CCrmOwnerType::isUseDynamicTypeBasedApproach($entityTypeId))
			{
				$descriptions[$entityTypeId] = $description;
			}
		}

		foreach ((array)$descriptions as $entityTypeId => $description)
		{
			$codes[$entityTypeId] = [
				'SYMBOL_CODE' => \CCrmOwnerType::ResolveName($entityTypeId),
				'SYMBOL_CODE_SHORT' => \CCrmOwnerTypeAbbr::ResolveByTypeID($entityTypeId),
			];
		}
	}
	elseif($name === 'ADDRESSTYPE')
	{
		$descriptions = EntityAddressType::getDescriptions(EntityAddressType::getAvailableIds());
	}
	elseif($name === 'CONTENTTYPE')
	{
		$descriptions = CCrmContentType::GetAllDescriptions();
	}
	elseif($name === 'ACTIVITYTYPE')
	{
		$descriptions = CCrmActivityType::GetAllDescriptions();
	}
	elseif($name === 'ACTIVITYPRIORITY')
	{
		$descriptions = CCrmActivityPriority::GetAllDescriptions();
	}
	elseif($name === 'ACTIVITYDIRECTION')
	{
		$descriptions = CCrmActivityDirection::GetAllDescriptions();
	}
	elseif($name === 'ACTIVITYNOTIFYTYPE')
	{
		$descriptions = CCrmActivityNotifyType::GetAllDescriptions();
	}
	elseif($name === 'ACTIVITYSTATUS')
	{
		$descriptions = CCrmActivityStatus::GetAllDescriptions();
	}
	elseif($name === 'ENTITYEDITOR')
	{
		if($nameSuffix === 'CONFIGURATION_SCOPE')
		{
			$descriptions = \Bitrix\Crm\Entity\EntityEditorConfigScope::getCaptions();
		}
	}

	if(!is_array($descriptions))
	{
		return parent::processMethodRequest($name, $nameDetails, $arParams, $nav, $server);
	}

	$result = array();
	foreach($descriptions as $k => $v)
	{
		$result[] = [
			'ID' => $k,
			'NAME' => $v,
			'SYMBOL_CODE' => $codes[$k]['SYMBOL_CODE'] ?? null,
			'SYMBOL_CODE_SHORT' => $codes[$k]['SYMBOL_CODE_SHORT'] ?? null,
		];
	}
	unset($v);
	return $result;
}

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