Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
eventhandler.php
1<?php
2
4
7use Bitrix\AI;
9
10final class EventHandler
11{
12 public const SETTINGS_ITEM_MAIL_CODE = 'mail_copilot_item_enabled';
13 public const SETTINGS_ITEM_MAIL_CRM_CODE = 'mail_crm_copilot_item_enabled';
14
15 public static function onTuningLoad(): Main\Entity\EventResult
16 {
17 $result = new Main\Entity\EventResult();
18 $items = [];
19
20 if (!self::checkTextCategory())
21 {
22 $result->modifyFields([
23 'items' => $items,
24 ]);
25
26 return $result;
27 }
28
30 'group' => AI\Tuning\Defaults::GROUP_TEXT,
31 'title' => Loc::getMessage('MAIL_INTEGRATION_AI_EVENTHANDLER_MAIL_SETTINGS_TITLE'),
32 'header' => Loc::getMessage('MAIL_INTEGRATION_AI_EVENTHANDLER_MAIL_SETTINGS_SUBTITLE'),
33 'type' => AI\Tuning\Type::BOOLEAN,
34 'default' => true,
35 'sort' => 400,
36 ];
37
38 if (Loader::includeModule('crm') && class_exists('\Bitrix\Crm\Integration\AI\AIManager'))
39 {
41 'group' => AI\Tuning\Defaults::GROUP_TEXT,
42 'title' => Loc::getMessage('MAIL_INTEGRATION_AI_EVENTHANDLER_MAIL_CRM_SETTINGS_TITLE'),
43 'header' => Loc::getMessage('MAIL_INTEGRATION_AI_EVENTHANDLER_MAIL_CRM_SETTINGS_SUBTITLE'),
44 'type' => AI\Tuning\Type::BOOLEAN,
45 'default' => true,
46 'sort' => 410,
47 ];
48 }
49
50 $result->modifyFields([
51 'items' => $items,
52 ]);
53
54 return $result;
55 }
56
57 private static function checkTextCategory():bool
58 {
59 return !empty(AI\Engine::getByCategory('text', AI\Context::getFake()));
60 }
61}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29