• Модуль: voximplant
  • Путь к файлу: ~/bitrix/modules/voximplant/lib/routing/router.php
  • Класс: BitrixVoximplantRoutingRouter
  • Вызов: Router::getNextAction
public function getNextAction(array $request = [])
{
	$this->call->removeAllInvitedUsers();
	$rootNode = $this->call->getExecutionGraph();
	if(!($rootNode instanceof Node))
	{
		$rootNode = $this->buildExecutionGraph($this->call);
		$this->call->updateExecutionGraph($rootNode);
	}

	if(!$rootNode)
	{
		return Action::create(Command::HANGUP, ['CODE' => 500, 'REASON' => 'Could not create call execution graph']);
	}
	$currentNode = $this->getCurrentNode($rootNode);
	if(!$currentNode)
	{
		return Action::create(Command::HANGUP, ['CODE' => 500, 'REASON' => 'No action found']);
	}

	$repeatedRun = ($currentNode->getId() === $this->call->getStage());

	if($repeatedRun)
	{
		$action = $currentNode->getNextAction($this->call, $request);
		// execution graph could be updated in process
		$this->call->updateExecutionGraph($rootNode);
		if($action)
		{
			$this->updateCallStateWithAction($action);
			return $action;
		}
	}

	$seenNodes = [];
	while($currentNode = $currentNode->getNext())
	{
		if($seenNodes[$currentNode->getId()] ?? null)
		{
			break;
		}

		$seenNodes[$currentNode->getId()] = true;
		$this->call->updateStage($currentNode->getId());
		$action = $currentNode->getFirstAction($this->call);
		// execution graph could be updated in process
		$this->call->updateExecutionGraph($rootNode);
		if($action)
		{
			$this->updateCallStateWithAction($action);
			return $action;
		}
	}
	return Action::create(Command::HANGUP, ['CODE' => 500, 'REASON' => 'No action found']);
}