1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
TextFieldEnabled.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Chat\TextField
;
4
5
use
Bitrix\Im\V2\Chat
;
6
use
Bitrix\Im\V2\Chat\Param\Params
;
7
use
Bitrix\Im\V2\Pull\Event\ChatFieldsUpdate
;
8
9
class
TextFieldEnabled
10
{
11
protected
int
$chatId
;
12
protected
Params
$params
;
13
14
public
function
__construct
(
int
$chatId
)
15
{
16
$this->chatId =
$chatId
;
17
$this->params = Params::getInstance(
$chatId
);
18
}
19
20
public
function
get
(): bool
21
{
22
$textFieldEnabled = $this->params->get(Params::TEXT_FIELD_ENABLED)?->getValue() ??
true
;
23
24
return
(
bool
)$textFieldEnabled;
25
}
26
27
public
function
set
(
bool
$value): self
28
{
29
if
(!$this->chatId)
30
{
31
return
$this;
32
}
33
34
$isChanged =
false
;
35
36
if
(!$value && $this->params->get(Params::TEXT_FIELD_ENABLED) ===
null
)
37
{
38
$this->params->addParamByName(Params::TEXT_FIELD_ENABLED,
false
);
39
$isChanged =
true
;
40
}
41
elseif
($value && $this->params->get(Params::TEXT_FIELD_ENABLED) !==
null
)
42
{
43
$this->params->deleteParam(Params::TEXT_FIELD_ENABLED);
44
$isChanged =
true
;
45
}
46
47
if
($isChanged)
48
{
49
$this->
sendPush
();
50
}
51
52
return
$this;
53
}
54
55
protected
function
sendPush
(): void
56
{
57
$chat =
Chat::getInstance
($this->chatId);
58
$updateField = [
'textFieldEnabled'
=> $this->
get
()];
59
(
new
ChatFieldsUpdate
($chat, $updateField))->send();
60
}
61
}
Bitrix\Im\V2\Chat\Param\Params
Определения
Params.php:21
Bitrix\Im\V2\Chat\TextField\TextFieldEnabled
Определения
TextFieldEnabled.php:10
Bitrix\Im\V2\Chat\TextField\TextFieldEnabled\sendPush
sendPush()
Определения
TextFieldEnabled.php:55
Bitrix\Im\V2\Chat\TextField\TextFieldEnabled\$chatId
int $chatId
Определения
TextFieldEnabled.php:11
Bitrix\Im\V2\Chat\TextField\TextFieldEnabled\$params
Params $params
Определения
TextFieldEnabled.php:12
Bitrix\Im\V2\Chat\TextField\TextFieldEnabled\__construct
__construct(int $chatId)
Определения
TextFieldEnabled.php:14
Bitrix\Im\V2\Pull\Event\ChatFieldsUpdate
Определения
ChatFieldsUpdate.php:10
Bitrix\Main\Application\getInstance
static getInstance()
Определения
application.php:98
Bitrix\Im\V2\Chat\TextField
Определения
TextFieldEnabled.php:3
Bitrix\Im\V2\Chat
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
im
lib
V2
Chat
TextField
TextFieldEnabled.php
Создано системой
1.14.0