ChannelInfo::compareBySort

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. ChannelInfo
  4. compareBySort
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/channel/channelinfo.php
  • Класс: Bitrix\Crm\Integration\Channel\ChannelInfo
  • Вызов: ChannelInfo::compareBySort
static function compareBySort(ChannelInfo $first, ChannelInfo $second)
{
	$firstSort = $first->sort;
	$firstGroupSort = -1;
	if($first->groupID !== '')
	{
		$firstGroup = ChannelTrackerManager::getGroupInfo($first->groupID);
		if($firstGroup !== null)
		{
			$firstGroupSort = $firstGroup->getSort();
		}
	}

	$secondSort = $second->sort;
	$secondGroupSort = -1;
	if($second->groupID !== '')
	{
		$secondGroup = ChannelTrackerManager::getGroupInfo($second->groupID);
		if($secondGroup !== null)
		{
			$secondGroupSort = $secondGroup->getSort();
		}
	}

	if($firstGroupSort > 0 && $secondGroupSort > 0 && $firstGroupSort !== $secondGroupSort)
	{
		return ($firstGroupSort - $secondGroupSort);
	}

	if($firstGroupSort > 0)
	{
		$firstSort += $firstGroupSort;
	}

	if($secondGroupSort > 0)
	{
		$secondSort += $secondGroupSort;
	}

	return ($firstSort - $secondSort);
}

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