History::loadStack

  1. Bitrix24 API (v. 23.675.0)
  2. landing
  3. History
  4. loadStack
  • Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/history.php
  • Класс: BitrixLandingHistory
  • Вызов: History::loadStack
protected function loadStack(): void
{
	// todo: maybe cache
	$this->stack = [];

	$res = HistoryTable::query()
		->addSelect('*')
		->where('ENTITY_TYPE', '=', $this->entityType)
		->where('ENTITY_ID', '=', $this->entityId)
		->setOrder(['ID' => 'ASC'])
		->exec()
	;
	$step = 1;
	$multyId = null;
	while ($row = $res->fetch())
	{
		$row['ID'] = (int)$row['ID'];
		if (!is_array($row['ACTION_PARAMS']))
		{
			$this->fixBrokenStep($step, $row['ID']);
			continue;
		}

		$row['STEP'] = $step;
		$row['ENTITY_ID'] = (int)$row['ENTITY_ID'];
		$row['MULTIPLY_ID'] = (int)$row['MULTIPLY_ID'];

		if ($row['MULTIPLY_ID'])
		{
			if ($multyId && $multyId !== $row['MULTIPLY_ID'])
			{
				$multyId = null;
			}

			if (!$multyId)
			{
				// first multiply step
				$row['ACTION_PARAMS'] = [
					[
						'ACTION' => $row['ACTION'],
						'ACTION_PARAMS' => $row['ACTION_PARAMS'],
					],
				];
				$row['ACTION'] = ActionFactory::MULTIPLY_ACTION_NAME;
				$multyId = $row['MULTIPLY_ID'];
				$row['MULTIPLY'] = [$row['MULTIPLY_ID']];
				unset($row['MULTIPLY_ID']);
				$this->stack[$step] = $row;
			}
			else
			{
				$this->stack[$step - 1]['ACTION_PARAMS'][] = [
					'ACTION' => $row['ACTION'],
					'ACTION_PARAMS' => $row['ACTION_PARAMS'],
				];
				$this->stack[$step - 1]['MULTIPLY'][] = $row['ID'];
			}
		}
		else
		{
			$multyId = null;
			$this->stack[$step] = $row;
		}

		$step++;
	}
}

Добавить комментарий