Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
messageparam.php
1<?php declare(strict_types=1);
2
3namespace Bitrix\Im\Services;
4
11{
13 private $isEnabled;
14
15 public function __construct()
16 {
17 $this->isEnabled = \Bitrix\Main\Loader::includeModule('im');
18 }
19
28 public function getParams(int $messageId, bool $withDefault = false): ?array
29 {
30 if ($this->isEnabled)
31 {
32 return \CIMMessageParam::Get($messageId, false, $withDefault);
33 }
34
35 return null;
36 }
37
47 public function getParam(int $messageId, string $name, bool $withDefault = false)
48 {
49 if ($this->isEnabled)
50 {
51 return \CIMMessageParam::Get($messageId, $name, $withDefault);
52 }
53
54 return null;
55 }
56
66 public function setParams(int $messageId, array $values, bool $sendPull = true): bool
67 {
68 if ($this->isEnabled)
69 {
70 if ($sendPull)
71 {
72 return
73 \CIMMessageParam::Set($messageId, $values)
74 && \CIMMessageParam::SendPull($messageId, array_keys($values))
75 ;
76 }
77 else
78 {
79 return \CIMMessageParam::Set($messageId, $values);
80 }
81 }
82
83 return false;
84 }
85
96 public function setParam(int $messageId, string $name, $value, bool $sendPull = true): bool
97 {
98 if ($this->isEnabled)
99 {
100 if ($sendPull)
101 {
102 return
103 \CIMMessageParam::Set($messageId, [$name => $value])
104 && \CIMMessageParam::SendPull($messageId, [$name])
105 ;
106 }
107 else
108 {
109 return \CIMMessageParam::Set($messageId, [$name => $value]);
110 }
111 }
112
113 return false;
114 }
115}
getParam(int $messageId, string $name, bool $withDefault=false)
setParams(int $messageId, array $values, bool $sendPull=true)
getParams(int $messageId, bool $withDefault=false)
setParam(int $messageId, string $name, $value, bool $sendPull=true)