• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/connector/crm.php
  • Класс: BitrixLandingConnectorCrm
  • Вызов: Crm::getContacts
static function getContacts(int $siteId): array
{
	$cache = new CPHPCache;
	$cacheManager = $GLOBALS['CACHE_MANAGER'];
	$cacheTag = self::CACHE_TAG;
	$cacheDir = '/landing/crm_contacts';
	if ($cache->initCache(8640000, $cacheTag . $siteId, $cacheDir))
	{
		return $cache->getVars();
	}

	$cache->startDataCache();
	$cacheManager->startTagCache($cacheDir);
	$cacheManager->registerTag($cacheTag);

	$contacts = self::getContactsRaw();
	if (!$contacts)
	{
		$contacts = self::DEFAULT_CONTACTS;
	}

	$shopData = unserialize(Manager::getOption(self::OPTION_DATA_CODE, ''), ['allowed_classes' => false]);
	if (isset($shopData[$siteId]))
	{
		$contacts = array_merge(
			$contacts,
			$shopData[$siteId]
		);
	}

	foreach ($contacts as &$value)
	{
		if (is_array($value))
		{
			$value = array_shift($value);
		}
	}
	unset($value);

	$cacheManager->endTagCache();
	$cache->endDataCache($contacts);

	return $contacts;
}