• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/internals/counter/counterstate.php
  • Класс: BitrixTasksInternalsCounterCounterState
  • Вызов: CounterState::loadFlags
private function loadFlags(): ?array
{
	$cache = Cache::createInstance();

	if ($cache->initCache(self::CACHE_TTL, $this->getCacheTag(), $this->getCacheDir()))
	{
		$rows = $cache->getVars();
	}
	else
	{
		$rows = CounterTable::query()
			->setSelect([
				'VALUE',
				'TASK_ID',
				'GROUP_ID',
				'TYPE'
			])
			->where('USER_ID', $this->userId)
			->whereIn('TYPE', [CounterDictionary::COUNTER_FLAG_COUNTED, CounterDictionary::COUNTER_FLAG_CLEARED])
			->setLimit(2)
			->fetchAll();

		if (!empty($rows))
		{
			$taggedCache = Application::getInstance()->getTaggedCache();
			$taggedCache->StartTagCache($this->getCacheDir());
			$taggedCache->RegisterTag($this->getCacheTag());

			$cache->startDataCache();
			$cache->endDataCache($rows);
			$taggedCache->EndTagCache();
		}
	}

	foreach ($rows as $row)
	{
		switch ($row['TYPE'])
		{
			case CounterDictionary::COUNTER_FLAG_COUNTED:
				$this->flagCounted = (int) $row['VALUE'];
				break;
			case CounterDictionary::COUNTER_FLAG_CLEARED:
				$this->flagCleared = (int) $row['VALUE'];
				break;
		}
	}

	return $rows ? $rows : null;
}