- Модуль: rest
- Путь к файлу: ~/bitrix/modules/rest/lib/engine/access.php
- Класс: BitrixRestEngineAccess
- Вызов: Access::isAvailableCount
static function isAvailableCount(string $entityType, $entity = 0) : bool
{
if (!static::isActiveRules())
{
return true;
}
$key = $entityType . $entity;
if (!array_key_exists($key, static::$availableAppCount))
{
static::$availableAppCount[$key] = true;
if ($entityType === static::ENTITY_TYPE_APP)
{
$maxCount = static::getAvailableCount();
if ($maxCount >= 0)
{
$appInfo = AppTable::getByClientId($entity);
if (!isset($appInfo['STATUS']) || $appInfo['STATUS'] !== AppTable::STATUS_LOCAL)
{
if (isset($appInfo['CODE']) && $appInfo['CODE'])
{
$entity = $appInfo['CODE'];
}
$entityList = static::getActiveEntity(true);
if ($entityList[static::ENTITY_COUNT] > $maxCount)
{
static::$availableAppCount[$key] = false;
}
elseif (
$entityList[static::ENTITY_COUNT] === $maxCount
&& !in_array($entity, $entityList[$entityType], true)
)
{
static::$availableAppCount[$key] = false;
}
if (
static::$availableAppCount[$key] === false
&& (
in_array($entity, Immune::getList(), true)
|| (
!static::needCheckCount()
&& in_array($entity, $entityList[$entityType], true)
)
)
)
{
static::$availableAppCount[$key] = true;
}
}
}
}
}
return static::$availableAppCount[$key];
}