Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
eventhandler.php
1
<?php
2
3
namespace
Bitrix\Mail\Integration\AI
;
4
5
use
Bitrix\Main\Loader
;
6
use
Bitrix\Main\Localization\Loc
;
7
use Bitrix\AI;
8
use
Bitrix\Main
;
9
10
final
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'
),
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
}
Bitrix\Mail\Integration\AI\EventHandler
Definition
eventhandler.php:11
Bitrix\Mail\Integration\AI\EventHandler\onTuningLoad
static onTuningLoad()
Definition
eventhandler.php:15
Bitrix\Mail\Integration\AI\EventHandler\SETTINGS_ITEM_MAIL_CRM_CODE
const SETTINGS_ITEM_MAIL_CRM_CODE
Definition
eventhandler.php:13
Bitrix\Mail\Integration\AI\EventHandler\SETTINGS_ITEM_MAIL_CODE
const SETTINGS_ITEM_MAIL_CODE
Definition
eventhandler.php:12
Bitrix\Main\EventResult
Definition
eventresult.php:5
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Mail\Integration\AI
Definition
controller.php:3
Bitrix\Main
modules
mail
lib
integration
ai
eventhandler.php
Создано системой
1.10.0