1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Menu.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Message\Param;
4
5use Bitrix\Im;
6use Bitrix\Im\V2\Message\Param;
7use Bitrix\Im\V2\Result;
8use Bitrix\Main\ArgumentException;
9
10class Menu extends Param
11{
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 {
32 }
33
34 if (isset($this->menu))
35 {
36 $this->value = $this->menu->getArray();
37 $this->jsonValue = $this->menu->getJson();
38 }
39
40 return $this;
41 }
42
46 public function getValue()
47 {
48 return $this->value ?? $this->getDefaultValue();
49 }
50
51 public function getDefaultValue()
52 {
53 return 'N';
54 }
55
60 public function saveValueFilter($value)
61 {
62 return '';
63 }
64
69 public function saveJsonFilter($value)
70 {
71 return $this->jsonValue;
72 }
73
78 public function loadJsonFilter($value)
79 {
80 if (!empty($value))
81 {
82 try
83 {
85 }
86 catch (ArgumentException $ext)
87 {}
88 }
89 else
90 {
91 $value = null;
92 }
93
94 return $value;
95 }
96
100 public function toRestFormat()
101 {
102 return $this->getValue();
103 }
104
108 public function toPullFormat()
109 {
110 return $this->getValue();
111 }
112
116 public function isValid(): Result
117 {
118 $result = new Result();
119
120 if ($this->isValid && (!isset($this->menu) || $this->menu->IsAllowSize()))
121 {
122 return $result;
123 }
124
125 return $result->addError(new ParamError(ParamError::MENU_ERROR));
126 }
127}
static getByJson($params, $textReplace=array(), $options=Array())
Определения contextmenu.php:83
bool $isValid
Определения Menu.php:13
setValue($value)
Определения Menu.php:19
Im Bot ContextMenu $menu
Определения Menu.php:12
saveJsonFilter($value)
Определения Menu.php:69
loadJsonFilter($value)
Определения Menu.php:78
saveValueFilter($value)
Определения Menu.php:60
getDefaultValue()
Определения Menu.php:51
unsetValue()
Определения Param.php:223
string $jsonValue
Определения Param.php:49
Определения result.php:20
static decode($data)
Определения json.php:50
$result
Определения get_property_values.php:14
Определения contextmenu.php:9
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393