• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/restriction/bitrix24searchlimitrestriction.php
  • Класс: Bitrix\Crm\Restriction\Bitrix24SearchLimitRestriction
  • Вызов: Bitrix24SearchLimitRestriction::getCount
public function getCount($entityTypeId): int
{
	$cacheId = 'crm_search_restriction_count_' . $entityTypeId;

	if ($this->cache->initCache(self::CACHE_TTL, $cacheId, self::CACHE_DIR))
	{
		return (int)$this->cache->getVars()['count'];
	}

	$this->cache->startDataCache();

	if ($entityTypeId === CCrmOwnerType::Lead)
	{
		$count = \CCrmLead::GetTotalCount();
	}
	elseif ($entityTypeId === CCrmOwnerType::Deal)
	{
		$count = \CCrmDeal::GetTotalCount();
	}
	elseif ($entityTypeId === CCrmOwnerType::Company)
	{
		$count = \CCrmCompany::GetTotalCount();
	}
	elseif ($entityTypeId === CCrmOwnerType::Contact)
	{
		$count = \CCrmContact::GetTotalCount();
	}
	elseif ($entityTypeId === CCrmOwnerType::Quote)
	{
		$count = \CCrmQuote::GetTotalCount();
	}
	elseif ($entityTypeId === CCrmOwnerType::Invoice)
	{
		$count = \CCrmInvoice::GetTotalCount();
	}
	elseif ($entityTypeId === CCrmOwnerType::Order)
	{
		$count = Manager::countTotal();
	}
	else
	{
		$factory = Container::getInstance()->getFactory($entityTypeId);
		if ($factory)
		{
			$count = $factory->getItemsCount();
		}
		elseif (CCrmOwnerType::isUseDynamicTypeBasedApproach($entityTypeId))
		{
			return 0;
		}
		else
		{
			$entityTypeName = CCrmOwnerType::ResolveName($entityTypeId);

			throw new NotSupportedException("Entity type: '{$entityTypeName}' is not supported in current context");
		}
	}
	
	$this->cache->endDataCache(['count' => $count]);

	return $count;
}