1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
TextFieldEnabled.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Chat\Fields\Field;
4
5use Bitrix\Im\V2\Chat;
6use Bitrix\Im\V2\Chat\Fields\BaseField;
7use Bitrix\Im\V2\Chat\Param\Params;
8use Bitrix\Im\V2\Pull\Event\ChatFieldsUpdate;
9
11{
12 protected Params $params;
13
14 public function __construct(int $chatId)
15 {
16 parent::__construct($chatId);
17 $this->params = Params::getInstance($chatId);
18 }
19
23 public function get(): bool
24 {
25 return $this->params->get(Params::TEXT_FIELD_ENABLED)?->getValue() ?? true;
26 }
27
32 public function set(mixed $value): self
33 {
34 $isChanged = false;
35 $value = (bool)$value;
36
37 if (!$value && $this->params->get(Params::TEXT_FIELD_ENABLED) === null)
38 {
39 $this->params->addParamByName(Params::TEXT_FIELD_ENABLED, false);
40 $isChanged = true;
41 }
42 elseif ($value && $this->params->get(Params::TEXT_FIELD_ENABLED) !== null)
43 {
44 $this->params->deleteParam(Params::TEXT_FIELD_ENABLED);
45 $isChanged = true;
46 }
47
48 if ($isChanged)
49 {
50 $this->sendPush();
51 }
52
53 return $this;
54 }
55
56 protected function sendPush(): void
57 {
58 $chat = Chat::getInstance($this->chatId);
59 $updateField = ['optionalParams' => [$this->getFieldName() => $this->get()]];
60 (new ChatFieldsUpdate($chat, $updateField))->send();
61 }
62
63 protected function getFieldName(): string
64 {
65 return 'textFieldEnabled';
66 }
67
68 public function toRestFormat(array $option = []): array
69 {
70 $enableTextField = $this->get();
71
72 if ($enableTextField)
73 {
74 return [];
75 }
76
77 return [$this->getFieldName() => false];
78 }
79}
static getInstance()
Определения application.php:98
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$option
Определения options.php:1711