CCrmComponentHelper::prepareClientEditorFieldsParams

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmComponentHelper
  4. prepareClientEditorFieldsParams
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_component_helper.php
  • Класс: \CCrmComponentHelper
  • Вызов: CCrmComponentHelper::prepareClientEditorFieldsParams
static function prepareClientEditorFieldsParams(array $params = []): array
{
	$result = [];

	$entityTypeCategoryMap = [
		CCrmOwnerType::Contact => 0,
		CCrmOwnerType::Company => 0,
	];

	$entityTypeMap = [];
	if (isset($params['entityTypes']) && is_array($params['entityTypes']))
	{
		foreach($params['entityTypes'] as $entityTypeId)
		{
			if (is_int($entityTypeId) && isset($entityTypeCategoryMap[$entityTypeId]))
			{
				$entityTypeMap[$entityTypeId] = true;
			}
		}
	}

	if (isset($params['categoryParams']) && is_array($params['categoryParams']))
	{
		foreach (array_keys($entityTypeCategoryMap) as $entityTypeId)
		{
			if (
				isset($params['categoryParams'][$entityTypeId])
				&& is_array($params['categoryParams'][$entityTypeId])
				&& isset($params['categoryParams'][$entityTypeId]['categoryId'])
				&& is_int($params['categoryParams'][$entityTypeId]['categoryId'])
				&& $params['categoryParams'][$entityTypeId]['categoryId'] > 0
			)
			{
				$entityTypeCategoryMap[$entityTypeId] = $params['categoryParams'][$entityTypeId]['categoryId'];
			}
		}
	}

	$isLocationModuleIncluded = Main\Loader::includeModule('location');

	foreach (array_keys($entityTypeCategoryMap) as $entityTypeId)
	{
		if (empty($entityTypeMap) || isset($entityTypeMap[$entityTypeId]))
		{
			$entityTypeName = CCrmOwnerType::ResolveName($entityTypeId);
			$result[$entityTypeName] = [
				'REQUISITES' => static::getFieldInfoData($entityTypeId, 'requisite')
			];
			if ($isLocationModuleIncluded)
			{
				$result[$entityTypeName]['ADDRESS'] =
					static::getRequisiteAddressFieldData($entityTypeId, $entityTypeCategoryMap[$entityTypeId])
				;
			}
		}
	}

	return $result;
}

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