Item::getFieldOptions

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Item
  4. getFieldOptions
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/bizproc/document/item.php
  • Класс: Bitrix\Crm\Integration\BizProc\Document\Item
  • Вызов: Item::getFieldOptions
static function getFieldOptions(array $field, Crm\Service\Factory $factory): ?array
{
	if (array_key_exists('CLASS', $field))
	{
		switch ($field['CLASS'])
		{
			case Crm\Field\Category::class:
				$categories = [];
				foreach (static::getCategories($factory) as $category)
				{
					$categories[$category->getId()] = $category->getName();
				}

				return $categories;

			case Crm\Field\PreviousStageId::class:
			case Crm\Field\Stage::class:
				$stages = [];
				$categories = static::getCategories($factory) ?: [null];
				foreach ($categories as $category)
				{
					foreach (static::getStages($factory, $category) as $stage)
					{
						$stagePrefix = isset($category) ? $category->getName() . '/' : '';
						$stages[$stage['STATUS_ID']] = $stagePrefix . $stage['NAME'];
					}
				}

				return $stages;
		}
	}

	switch ($field['TYPE'])
	{
		case 'crm_contact':
			return ['CONTACT' => 'Y'];

		case 'crm_company':
			return ['COMPANY' => 'Y'];

		case 'crm_deal':
		case 'crm_entity':
		case 'crm_lead':
			if (isset($field['SETTINGS'], $field['SETTINGS']['parentEntityTypeId']))
			{
				$entityType = \CCrmOwnerType::ResolveName($field['SETTINGS']['parentEntityTypeId']);

				return [$entityType => 'Y'];
			}

			return null;

		case 'crm_status':
			return
				array_key_exists('CRM_STATUS_TYPE', $field)
					? \CCrmStatus::GetStatusList($field['CRM_STATUS_TYPE'])
					: []
			;

		case 'crm_currency':
			return \CCrmCurrencyHelper::PrepareListItems();

		default:
			return null;
	}
}

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