• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/clientresolver.php
  • Класс: Bitrix\Crm\Integration\ClientResolver
  • Вызов: ClientResolver::getDetailSearchHandlersByCountry
static function getDetailSearchHandlersByCountry(bool $noStaticCache = false): array
{
	static $result = null;


	if ($result === null || $noStaticCache)
	{
		$result = [];
		if (static::isRestModuleIncluded())
		{
			$allowedCountriesMap = array_fill_keys(EntityRequisite::getAllowedRqFieldCountries(), true);
			$handlers = PlacementTable::getHandlersList(AppPlacement::REQUISITE_AUTOCOMPLETE);
			foreach ($handlers as $hadnlerInfo)
			{
				$filteredHandlerInfo = [
					'ID' => $hadnlerInfo['ID'],
					'TITLE' => $hadnlerInfo['TITLE'],
					'OPTIONS' => $hadnlerInfo['OPTIONS'],
				];
				$countries = [];
				if (
					isset($filteredHandlerInfo['OPTIONS']['countries'])
					&& is_string($filteredHandlerInfo['OPTIONS']['countries'])
					&& $filteredHandlerInfo['OPTIONS']['countries'] !== ''
				)
				{
					$optionValue = $filteredHandlerInfo['OPTIONS']['countries'];
					if (preg_match('/^[1-9][0-9]*(,[1-9][0-9]*)*$/', $optionValue))
					{
						$countryList = explode(',', $filteredHandlerInfo['OPTIONS']['countries']);
						if (is_array($countryList))
						{
							foreach ($countryList as $countryId)
							{
								$countryId = (int)$countryId;
								if (isset($allowedCountriesMap[$countryId]))
								{
									$countries[$countryId] = true;
								}
							}
							$countries = array_keys($countries);
						}
					}
				}
				if (empty($countries))
				{
					$countries = EntityRequisite::getAllowedRqFieldCountries();
				}
				foreach ($countries as $countryId)
				{
					if (!is_array($result[$countryId]))
					{
						$result[$countryId] = [];
					}
					$result[$countryId][] = $filteredHandlerInfo;
				}
			}
		}
	}

	return $result;
}