FieldCategory::getCategoryByPath

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. FieldCategory
  4. getCategoryByPath
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integrity/volatile/fieldcategory.php
  • Класс: Bitrix\Crm\Integrity\Volatile\FieldCategory
  • Вызов: FieldCategory::getCategoryByPath
public function getCategoryByPath(string $fieldPathName): array
{
	$result = [
		'categoryId' => static::UNDEFINED,
		'categoryPrefixTitle' => '',
		'params' => [],
	];

	$fieldInfo = FieldInfo::getInstance();

	[$path, $name] = array_values($fieldInfo->splitFieldPath($fieldPathName));

	$fieldPathLength = mb_strlen($path);
	if ($fieldPathLength <= 0)
	{
		if ($name === 'ADDRESS')
		{
			$result['categoryId'] = static::ADDRESS;
		}
		else
		{
			$result['categoryId'] = static::ENTITY;
		}
	}
	else
	{
		$subTypeCode1 = ($fieldPathLength >= 2) ? mb_substr($path, 0, 2) : '';
		if ($fieldPathLength === 2)
		{
			if ($subTypeCode1 === FieldCategory::PREFIX_MULTI)
			{
				$multiFieldType = $name;
				$multiFieldTypeMap = CCrmFieldMulti::GetEntityTypes();
				if (isset($multiFieldTypeMap[$multiFieldType]))
				{
					$result['categoryId'] = static::MULTI;
					$result['params']['multiFieldType'] = $multiFieldType;
				}
			}
			elseif ($subTypeCode1 === FieldCategory::PREFIX_REQUISITE)
			{
				if ($name === EntityRequisite::ADDRESS)
				{
					$result['categoryId'] = static::ADDRESS;
				}
			}
		}
		elseif (
			$fieldPathLength >= 5 && $path[2] === '.'
			&& $subTypeCode1 === FieldCategory::PREFIX_REQUISITE
		)
		{
			$countryCode = mb_substr($path, 3, 2);
			$countryId = (int)GetCountryIdByCode($countryCode);

			if ($fieldPathLength === 5)
			{
				$result['categoryId'] = static::REQUISITE;
				$result['params']['countryId'] = $countryId;
			}
			elseif ($countryId > 0 && $fieldPathLength === 8 && $path[5] === '.')
			{
				$subTypeCode2 = mb_substr($path, 6);
				if ($subTypeCode2 === FieldCategory::PREFIX_BANK_DETAIL)
				{
					$result['categoryId'] = static::BANK_DETAIL;
					$result['params']['countryId'] = $countryId;
				}
			}
		}
	}

	$result['categoryPrefixTitle'] = $this->getCategoryPrefixTitle($result['categoryId']);

	return $result;
}

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