1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
eventhandler.php
См. документацию.
1<?php
2
3namespace Bitrix\Mail\Integration\AI;
4
5use Bitrix\Main\Loader;
6use Bitrix\Main\Localization\Loc;
7use Bitrix\AI;
8use Bitrix\Main;
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
29 $items[self::SETTINGS_ITEM_MAIL_CODE] = [
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 {
40 $items[self::SETTINGS_ITEM_MAIL_CRM_CODE] = [
41 'group' => AI\Tuning\Defaults::GROUP_TEXT,
42 'title' => Loc::getMessage('MAIL_INTEGRATION_AI_EVENTHANDLER_MAIL_CRM_SETTINGS_TITLE_MSGVER_1'),
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}
$result
Определения get_property_values.php:14
Определения ufield.php:9
$items
Определения template.php:224