• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/conversion/entityconversionconfig.php
  • Класс: Bitrix\Crm\Conversion\EntityConversionConfig
  • Вызов: EntityConversionConfig::getScheme
public function getScheme(): Scheme
{
	if ($this->scheme === null)
	{
		$oldScheme = ConversionManager::getSchemeClass($this->srcEntityTypeID);
		$activeEntityTypeIds = [];
		$currentSchemeId = null;
		$activeItems = $this->getActiveItems();
		foreach ($activeItems as $activeItem)
		{
			$activeEntityTypeIds[] = $activeItem->getEntityTypeID();
		}
		sort($activeEntityTypeIds);

		$items = [];
		foreach ($oldScheme::getAllDescriptions() as $schemeId => $phrase)
		{
			$entityTypeIds = $oldScheme::getEntityTypeIds($schemeId);
			$item =
				(new SchemeItem($entityTypeIds, $phrase))
					->setId($schemeId)
			;

			$items[] = $item;

			if ($entityTypeIds === $activeEntityTypeIds)
			{
				$currentSchemeId = $item->getId();
			}
		}

		foreach ($this->items as $item)
		{
			$typeId = $item->getEntityTypeID();
			if (\CCrmOwnerType::isUseDynamicTypeBasedApproach($typeId))
			{
				$entityTypeIds = [$typeId];
				$item = (new SchemeItem($entityTypeIds, \CCrmOwnerType::GetDescription($typeId)));

				$items[] = $item;

				if ($entityTypeIds === $activeEntityTypeIds)
				{
					$currentSchemeId = $item->getId();
				}
			}
		}

		$this->scheme = new Scheme($items);
		if ($currentSchemeId)
		{
			$this->scheme->setCurrentItemId($currentSchemeId);
		}
	}

	return $this->scheme;
}