Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
Menu.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Message\Param
;
4
5
use
Bitrix\Im
;
6
use
Bitrix\Im\V2\Message\Param
;
7
use
Bitrix\Im\V2\Result
;
8
use
Bitrix\Main\ArgumentException
;
9
10
class
Menu
extends
Param
11
{
12
protected
?
Im\Bot\ContextMenu
$menu
;
13
protected
bool
$isValid
=
true
;
14
19
public
function
setValue
(
$value
): self
20
{
21
if
(
$value
===
null
||
$value
=== $this->
getDefaultValue
())
22
{
23
return
$this->
unsetValue
();
24
}
25
if
(
$value
instanceof Im\
Bot
\ContextMenu)
26
{
27
$this->menu =
$value
;
28
}
29
elseif (!empty(
$value
))
30
{
31
$this->menu = Im\Bot\ContextMenu::getByJson(
$value
);
32
if
($this->menu ===
null
)
33
{
34
$this->
isValid
=
false
;
35
}
36
}
37
38
if
(isset($this->menu))
39
{
40
$this->value = $this->menu->getArray();
41
$this->jsonValue = $this->menu->getJson();
42
}
43
44
return
$this;
45
}
46
50
public
function
getValue
()
51
{
52
return
$this->value ?? $this->
getDefaultValue
();
53
}
54
55
public
function
getDefaultValue
()
56
{
57
return
'N'
;
58
}
59
64
public
function
saveValueFilter
(
$value
)
65
{
66
return
''
;
67
}
68
73
public
function
loadValueFilter
(
$value
)
74
{
75
if
(!empty(
$value
))
76
{
77
$value
= Im\Text::decodeEmoji(
$value
);
78
}
79
else
80
{
81
$value
=
null
;
82
}
83
84
return
$value
;
85
}
86
91
public
function
saveJsonFilter
(
$value
)
92
{
93
return
$this->jsonValue
;
94
}
95
100
public
function
loadJsonFilter
(
$value
)
101
{
102
if
(!empty(
$value
))
103
{
104
try
105
{
106
$this->value = \Bitrix\Main\Web\Json::decode(
$value
);
107
}
108
catch
(
ArgumentException
$ext)
109
{}
110
}
111
else
112
{
113
$value
=
null
;
114
}
115
116
return
$value
;
117
}
118
122
public
function
toRestFormat
()
123
{
124
return
$this->
getValue
();
125
}
126
130
public
function
toPullFormat
()
131
{
132
return
$this->
getValue
();
133
}
134
138
public
function
isValid
():
Result
139
{
140
$result =
new
Result
();
141
142
if
($this->
isValid
&& (!isset($this->menu) || $this->menu->IsAllowSize()))
143
{
144
return
$result;
145
}
146
147
return
$result->addError(
new
ParamError
(
ParamError::MENU_ERROR
));
148
}
149
}
Bitrix\Im\Bot\ContextMenu
Definition
contextmenu.php:12
Bitrix\Im\Bot
Definition
bot.php:11
Bitrix\Im\V2\Message\Param\Menu
Definition
Menu.php:11
Bitrix\Im\V2\Message\Param\Menu\$isValid
bool $isValid
Definition
Menu.php:13
Bitrix\Im\V2\Message\Param\Menu\toPullFormat
toPullFormat()
Definition
Menu.php:130
Bitrix\Im\V2\Message\Param\Menu\setValue
setValue($value)
Definition
Menu.php:19
Bitrix\Im\V2\Message\Param\Menu\$menu
Im Bot ContextMenu $menu
Definition
Menu.php:12
Bitrix\Im\V2\Message\Param\Menu\isValid
isValid()
Definition
Menu.php:138
Bitrix\Im\V2\Message\Param\Menu\saveJsonFilter
saveJsonFilter($value)
Definition
Menu.php:91
Bitrix\Im\V2\Message\Param\Menu\loadJsonFilter
loadJsonFilter($value)
Definition
Menu.php:100
Bitrix\Im\V2\Message\Param\Menu\loadValueFilter
loadValueFilter($value)
Definition
Menu.php:73
Bitrix\Im\V2\Message\Param\Menu\getValue
getValue()
Definition
Menu.php:50
Bitrix\Im\V2\Message\Param\Menu\saveValueFilter
saveValueFilter($value)
Definition
Menu.php:64
Bitrix\Im\V2\Message\Param\Menu\toRestFormat
toRestFormat()
Definition
Menu.php:122
Bitrix\Im\V2\Message\Param\Menu\getDefaultValue
getDefaultValue()
Definition
Menu.php:55
Bitrix\Im\V2\Message\Param\ParamError
Definition
ParamError.php:9
Bitrix\Im\V2\Message\Param\ParamError\MENU_ERROR
const MENU_ERROR
Definition
ParamError.php:11
Bitrix\Im\V2\Message\Param
Definition
Param.php:19
Bitrix\Im\V2\Message\Param\$value
$value
Definition
Param.php:45
Bitrix\Im\V2\Message\Param\unsetValue
unsetValue()
Definition
Param.php:222
Bitrix\Im\V2\Message\Param\$jsonValue
string $jsonValue
Definition
Param.php:48
Bitrix\Im\V2\Result
Definition
Result.php:9
Bitrix\Main\ArgumentException
Definition
exception.php:34
Bitrix\Im\V2\Message\Param
Definition
Attach.php:3
Bitrix\Im
modules
im
lib
V2
Message
Param
Menu.php
Создано системой
1.10.0