• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integrity/volatile/fieldinfo.php
  • Класс: Bitrix\Crm\Integrity\Volatile\FieldInfo
  • Вызов: FieldInfo::sortCountries
protected function sortCountries(array $countries): array
{
	$result = [];

	if (empty($countries))
	{
		return $result;
	}

	$currentCountryId = EntityPreset::getCurrentCountryId();
	$countries = array_fill_keys($countries, true);
	$allowedCountries = EntityRequisite::getAllowedRqFieldCountries();
	if (isset($countries[$currentCountryId]) && in_array($currentCountryId, $allowedCountries, true))
	{
		$result[] = $currentCountryId;
	}
	foreach ($allowedCountries as $countryId)
	{
		if (isset($countries[$countryId]) && $countryId !== $currentCountryId)
		{
			$result[] = $countryId;
		}
	}

	return $result;
}