42 $type = $chat->getEntityType() ??
'';
43 if ($type === self::TYPE_SONET && Loader::includeModule(
'socialnetwork'))
47 elseif ($type === self::TYPE_TASKS && Loader::includeModule(
'tasks'))
51 elseif (Loader::includeModule(
'calendar') && $type === \CCalendar::CALENDAR_CHAT_ENTITY_TYPE)
55 elseif ($type === self::TYPE_CRM && Loader::includeModule(
'crm'))
57 $instance =
new CrmType($chat->getEntityId() ??
'');
59 elseif ($type === self::TYPE_CALL && Loader::includeModule(
'crm'))
61 $instance =
new CallType($chat->getEntityData1() ??
'');
63 elseif ($type === self::TYPE_MAIL && Loader::includeModule(
'mail'))
69 $instance =
new self();
72 $instance->type = $instance->type ?: $type;
73 $instance->chatId = $chat->getId() ?? 0;
74 $instance->entityId = $chat->getEntityId() ??
'';