CCrmComponentHelper::getEntityClientFieldCategoryParams

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmComponentHelper
  4. getEntityClientFieldCategoryParams
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_component_helper.php
  • Класс: \CCrmComponentHelper
  • Вызов: CCrmComponentHelper::getEntityClientFieldCategoryParams
static function getEntityClientFieldCategoryParams(int $entityTypeId, int $categoryId = 0, ?int $parentEntityTypeId = null): array
{
	if ($entityTypeId === CCrmOwnerType::SmartDocument || $parentEntityTypeId === CCrmOwnerType::SmartDocument)
	{
		$contactCategory = Container::getInstance()
			->getFactory(\CCrmOwnerType::Contact)
			->getCategoryByCode(\Bitrix\Crm\Service\Factory\SmartDocument::CONTACT_CATEGORY_CODE)
		;
		if ($contactCategory)
		{
			return [
				\CCrmOwnerType::Contact => [
					'categoryId' => $contactCategory->getId(),
					'extraCategoryIds' => [
						$categoryId
					]
				],
				\CCrmOwnerType::Company => [
					'categoryId' => $categoryId,
				]
			];
		}
	}

	return array_map(
		function ($categoryId)
		{
			return [
				'categoryId' => $categoryId,
			];
		},
		EntityTypeRelationsRepository::getInstance()->getMapByEntityTypeId(
			$entityTypeId,
			$categoryId
		)
	);
}

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