• Модуль: voximplant
  • Путь к файлу: ~/bitrix/modules/voximplant/lib/transfer/transferor.php
  • Класс: BitrixVoximplantTransferTransferor
  • Вызов: Transferor::initiateTransfer
static function initiateTransfer($parentCallId, $userId, $targetType, $targetId)
{
	$result = new Result();
	$parentCall = Call::load($parentCallId);
	if(!$parentCall)
	{
		return $result->addError(new Error('Parent call is not found'));
	}
	$parentConfig = $parentCall->getConfig();
	if(!isset($parentConfig['ID']))
	{
		return $result->addError(new Error('Parent call has empty config'));
	}
	
	if(is_array($parentConfig['FORWARD_LINE']))
	{
		$forwardConfig = $parentConfig['FORWARD_LINE'];
	}
	else
	{
		$forwardConfig = CVoxImplantConfig::GetBriefConfig(['ID' => $parentConfig['ID']]);
	}

	$transferCall = Call::create([
		'CALL_ID' => static::createCallId(),
		'PARENT_CALL_ID' => $parentCallId,
		'CONFIG_ID' => $forwardConfig['ID'],
		'USER_ID' => $userId,
		'INCOMING' => CVoxImplantMain::CALL_OUTGOING,
		'CALLER_ID' => static::createCallerId($targetType, $targetId),
		'ACCESS_URL' => $parentCall->getAccessUrl(),
		'STATUS' => CallTable::STATUS_WAITING,
		'DATE_CREATE' => new DateTime(),
		'LAST_PING' => null,
		'QUEUE_ID' => null,
	]);


	$transferCall->addUsers([$userId], CallUserTable::ROLE_CALLER, CallUserTable::STATUS_CONNECTED);
	$sendResult = $transferCall->getScenario()->sendStartTransfer($userId, $transferCall->getCallId(), $forwardConfig, true);
	if (!$sendResult->isSuccess())
	{
		return $result->addErrors($sendResult->getErrors());
	}

	$result->setData([
		'CALL' => $transferCall->toArray()
	]);

	return $result;
}