1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Keyboard.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 Keyboard 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
26 if ($value instanceof Im\Bot\Keyboard)
27 {
28 $this->keyboard = $value;
29 }
30 elseif (!empty($value))
31 {
33 }
34
35 if (isset($this->keyboard))
36 {
37 $this->value = $this->keyboard->getArray();
38 $this->jsonValue = $this->keyboard->getJson();
39 }
40
41 return $this;
42 }
43
47 public function getValue()
48 {
49 return $this->value ?? $this->getDefaultValue();
50 }
51
52 public function getDefaultValue()
53 {
54 return 'N';
55 }
56
61 public function saveValueFilter($value)
62 {
63 return '';
64 }
65
70 public function saveJsonFilter($value)
71 {
72 return $this->jsonValue;
73 }
74
79 public function loadJsonFilter($value)
80 {
81 if (!empty($value))
82 {
83 try
84 {
86 }
87 catch (ArgumentException $ext)
88 {}
89 }
90 else
91 {
92 $value = null;
93 }
94
95 return $value;
96 }
97
101 public function toRestFormat()
102 {
103 return $this->getValue();
104 }
105
109 public function toPullFormat()
110 {
111 return $this->getValue();
112 }
113
117 public function isValid(): Result
118 {
119 $result = new Result();
120
121 if ($this->isValid && (!isset($this->keyboard) || $this->keyboard->IsAllowSize()))
122 {
123 return $result;
124 }
125
126 return $result->addError(new ParamError(ParamError::KEYBOARD_ERROR));
127 }
128}
static getKeyboardByJson($params, $textReplace=array(), $options=Array())
Определения keyboard.php:196
Im Bot Keyboard $keyboard
Определения Keyboard.php:12
saveJsonFilter($value)
Определения Keyboard.php:70
loadJsonFilter($value)
Определения Keyboard.php:79
saveValueFilter($value)
Определения Keyboard.php:61
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