1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
TextFieldEnabled.php
См. документацию.
1<?php
2
4
8
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}
static getInstance()
Определения application.php:98
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393