• Модуль: voximplant
  • Путь к файлу: ~/bitrix/modules/voximplant/lib/routing/router.php
  • Класс: BitrixVoximplantRoutingRouter
  • Вызов: Router::buildOutgoingExecutionGraph
protected function buildOutgoingExecutionGraph(Call $call)
{
	$rootNode = new Root();
	$lastNode = $rootNode;

	$phoneNumber = $call->getCallerId();

	if ($phoneNumber === '')
	{
		$rootNode->setNext(new Hangup(404, 'Not found'));
		return $rootNode;
	}

	$queueId = 0;
	$userId = 0;

	if(mb_strpos($phoneNumber, 'queue:') === 0)
	{
		$queueId = (int)mb_substr($phoneNumber, 6);
	}
	else if(mb_strpos($phoneNumber, 'user:') === 0)
	{
		$userId = (int)mb_substr($phoneNumber, 5);
	}
	else
	{
		$entityInfo = CVoxImplantIncoming::getByInternalPhoneNumber($phoneNumber);
		if($entityInfo)
		{
			if ($entityInfo['ENTITY_TYPE'] === 'user')
			{
				$userId = $entityInfo['ENTITY_ID'];
			}
			else
			{
				$queueId = $entityInfo['ENTITY_ID'];
			}
		}
	}

	if($userId)
	{
		list($userNode, $nextNode) = static::buildUserGraph($userId, 'direct', CVoxImplantIncoming::RULE_HUNGUP);
		$lastNode->setNext($userNode);
	}
	else if($queueId)
	{
		$queueNode = static::buildQueueGraph($queueId, false);
		if($queueNode instanceof Node)
		{
			$lastNode->setNext($queueNode);
		}
	}
	else
	{
		$securityNode = new SecurityCheck();
		$lastNode->setNext($securityNode);

		$pstnNode = new Pstn($phoneNumber, CVoxImplantIncoming::RULE_HUNGUP);
		$securityNode->setNext($pstnNode);
	}

	return $rootNode;
}