• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/controller/activity/gotochat.php
  • Класс: Bitrix\Crm\Controller\Activity\GoToChat
  • Вызов: GoToChat::getConfigAction
public function getConfigAction(int $entityTypeId, int $entityId): array
{
	$itemIdentifier = new ItemIdentifier($entityTypeId, $entityId);

	$availableChannels = $this->getAvailableChannels($itemIdentifier);

	$currentSender = $this->getCurrentSender();
	$currentChannelId = null;

	$data = [];
	/** @var Channel $channel */
	foreach ($availableChannels as $channel)
	{
		$isDefault = ($channel->isDefault() && !$currentChannelId);
		$id = $channel->getId();

		$senderCode = $channel->getSender()::getSenderCode();
		$fromList = $this->getPreparedFromList($channel);

		$canUse = (
			($senderCode === 'bitrix24' && $channel->getSender()::canUse())
			|| ($senderCode !== 'bitrix24' && $channel->canSendMessage())
		);

		if ($canUse && $isDefault && $currentSender === $senderCode)
		{
			$currentChannelId = $id;
		}

		$data[] = [
			'id' => $id,
			'default' => $isDefault,
			'fromList' => $fromList,
			'toList' => $this->getPreparedToList($channel),
			'name' => $channel->getName(),
			'shortName' => $channel->getShortName(),
			'canUse' => $canUse,
		];
 		}

	if ($currentChannelId === null)
	{
		$currentChannelId = $this->getFirstAvailableChannelId($data);
	}

	return [
		'region' => (Application::getInstance()->getLicense()->getRegion() ?? 'ru'),
		'channels' => $data,
		'currentSender' => $this->getCurrentSender(),
		'currentChannelId' => $currentChannelId,

		// @todo check this for all entity types
		'communications' => $this->getCommunications($entityTypeId, $entityId),
		'contactCenterUrl' => (
			Loader::includeModule('bitrix24')
				? '/contact_center/'
				: '/services/contact_center/'
		),
	];
}