• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/engine/access.php
  • Класс: BitrixRestEngineAccess
  • Вызов: Access::calcUsageEntity
static function calcUsageEntity()
{
	$result = [
		static::ENTITY_TYPE_APP => [],
		static::ENTITY_TYPE_APP_STATUS => [],
		static::ENTITY_COUNT => 0
	];
	$immuneList = Immune::getList();

	$res = AppTable::getList(
		[
			'filter' => [
				'=ACTIVE' => AppTable::ACTIVE,
			],
			'select' => [
				'CODE',
				'STATUS',
			],
		]
	);
	while ($item = $res->fetch())
	{
		if (!in_array($item['CODE'], $immuneList, true))
		{
			if (!isset($result[static::ENTITY_TYPE_APP_STATUS][$item['STATUS']]))
			{
				$result[static::ENTITY_TYPE_APP_STATUS][$item['STATUS']] = 0;
			}
			$result[static::ENTITY_TYPE_APP_STATUS][$item['STATUS']]++;

			if ($item['STATUS'] === AppTable::STATUS_LOCAL)
			{
				$result[static::ENTITY_TYPE_APP][] = $item['CODE'];
			}

			if ($item['STATUS'] === AppTable::STATUS_FREE)
			{
				$result[static::ENTITY_TYPE_APP][] = $item['CODE'];
				$result[static::ENTITY_COUNT]++;
			}
		}
	}

	return $result;
}