• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/widget/formhandler.php
  • Класс: BitrixImOpenLinesWidgetFormHandler
  • Вызов: FormHandler::initChat
private function initChat(): bool
{
	if (
		$this->session instanceof Session
		&& $this->session->getChat() instanceof Chat
	)
	{
		$this->chat = $this->session->getChat();
	}
	else
	{
		$this->chat = new Chat();
		if ($this->session instanceof Session)
		{
			$this->session->setChat($this->chat);
		}
	}
	if (!$this->chat->isDataLoaded())
	{
		$chatLoadResult = $this->chat->load(['USER_CODE' => $this->userCode, 'USER_ID' => $this->userId]);
		if (!$chatLoadResult)
		{
			$this->errorCollection->setError(new Error('Chat loading error', self::ERROR_CHAT_LOADING));

			return false;
		}
	}

	$this->clientChat = new Chat($this->clientChatId);

	return true;
}