• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/marketplace/client.php
  • Класс: BitrixRestMarketplaceClient
  • Вызов: Client::getCategoriesFull
static function getCategoriesFull($forceReload = false)
{
	$managedCache = Application::getInstance()->getManagedCache();

	$cacheId = 'rest|marketplace|categories|full|'.LANGUAGE_ID;

	$requestNeeded = true;

	if (
		$forceReload === false
		&& static::CATEGORIES_CACHE_TTL > 0
		&& $managedCache->read(static::CATEGORIES_CACHE_TTL, $cacheId)
	)
	{
		$result = $managedCache->get($cacheId);
		if (is_array($result))
		{
			$requestNeeded = false;
		}
		elseif (intval($result) > time())
		{
			$requestNeeded = false;
			$result = [];
		}
	}

	if ($requestNeeded)
	{
		$result = Transport::instance()->call(Transport::METHOD_GET_CATEGORIES);
		if (!is_array($result))
		{
			$result = time() + 300;
		}

		if (static::CATEGORIES_CACHE_TTL > 0)
		{
			$managedCache->set($cacheId, $result);
		}
	}

	return (is_array($result) ? $result : []);
}