1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
bot.php
См. документацию.
1<?php
2namespace Bitrix\Im\Model;
3
4use Bitrix\Im\V2\Entity\User\Data\BotData;
5use Bitrix\Main;
6use Bitrix\Main\ORM\Event;
7use Bitrix\Im\V2\Common\UpdateByFilterTrait;
8
9
36
37class BotTable extends Main\Entity\DataManager
38{
39 use UpdateByFilterTrait;
45 public static function getTableName()
46 {
47 return 'b_im_bot';
48 }
49
55 public static function getMap()
56 {
57 return array(
58 'BOT_ID' => array(
59 'data_type' => 'integer',
60 'primary' => true,
61 ),
62 'MODULE_ID' => array(
63 'data_type' => 'string',
64 'validation' => array(__CLASS__, 'validateModuleId'),
65 'required' => true,
66 ),
67 'CODE' => array(
68 'data_type' => 'string',
69 'required' => true,
70 'validation' => array(__CLASS__, 'validateBotCode'),
71 ),
72 'TYPE' => array(
73 'data_type' => 'string',
74 'validation' => array(__CLASS__, 'validateBotType'),
75 'default_value' => 'B',
76 ),
77 'CLASS' => array(
78 'data_type' => 'string',
79 'validation' => array(__CLASS__, 'validateToClass'),
80 ),
81 'LANG' => array(
82 'data_type' => 'string',
83 'validation' => array(__CLASS__, 'validateLanguage'),
84 'default_value' => '',
85 ),
86 'METHOD_BOT_DELETE' => array(
87 'data_type' => 'string',
88 'validation' => array(__CLASS__, 'validateToMethod'),
89 ),
90 'METHOD_MESSAGE_ADD' => array(
91 'data_type' => 'string',
92 'validation' => array(__CLASS__, 'validateToMethod'),
93 ),
94 'METHOD_MESSAGE_UPDATE' => array(
95 'data_type' => 'string',
96 'validation' => array(__CLASS__, 'validateToMethod'),
97 ),
98 'METHOD_MESSAGE_DELETE' => array(
99 'data_type' => 'string',
100 'validation' => array(__CLASS__, 'validateToMethod'),
101 ),
102 'METHOD_CONTEXT_GET' => array(
103 'data_type' => 'string',
104 'validation' => array(__CLASS__, 'validateToMethod'),
105 ),
106 'METHOD_WELCOME_MESSAGE' => array(
107 'data_type' => 'string',
108 'validation' => array(__CLASS__, 'validateToMethod'),
109 ),
110 'TEXT_PRIVATE_WELCOME_MESSAGE' => array(
111 'data_type' => 'text',
112 ),
113 'TEXT_CHAT_WELCOME_MESSAGE' => array(
114 'data_type' => 'text',
115 ),
116 'COUNT_MESSAGE' => array(
117 'data_type' => 'integer',
118 ),
119 'COUNT_COMMAND' => array(
120 'data_type' => 'integer',
121 ),
122 'COUNT_CHAT' => array(
123 'data_type' => 'integer',
124 ),
125 'COUNT_USER' => array(
126 'data_type' => 'integer',
127 ),
128 'APP_ID' => array(
129 'data_type' => 'string',
130 'validation' => array(__CLASS__, 'validateAppId'),
131 'default_value' => '',
132 ),
133 'VERIFIED' => array(
134 'data_type' => 'boolean',
135 'values' => array('N', 'Y'),
136 'default_value' => 'N',
137 ),
138 'OPENLINE' => array(
139 'data_type' => 'boolean',
140 'values' => array('N', 'Y'),
141 'default_value' => 'N',
142 ),
143 'HIDDEN' => array(
144 'data_type' => 'boolean',
145 'values' => array('N', 'Y'),
146 'default_value' => 'N',
147 ),
148 'BACKGROUND_ID' => array(
149 'data_type' => 'string',
150 'validation' => array(__CLASS__, 'validateBotCode'),
151 ),
152 );
153 }
154
160 public static function validateBotCode()
161 {
162 return array(
163 new Main\Entity\Validator\Length(null, 50),
164 );
165 }
166
172 public static function validateToClass()
173 {
174 return array(
175 new Main\Entity\Validator\Length(null, 255),
176 );
177 }
178
184 public static function validateModuleId()
185 {
186 return array(
187 new Main\Entity\Validator\Length(null, 255),
188 );
189 }
190
196 public static function validateToMethod()
197 {
198 return array(
199 new Main\Entity\Validator\Length(null, 255),
200 );
201 }
202
208 public static function validateAppId()
209 {
210 return array(
211 new Main\Entity\Validator\Length(null, 128),
212 );
213 }
214
220 public static function validateBotType()
221 {
222 return array(
223 new Main\Entity\Validator\Length(null, 1),
224 );
225 }
226
232 public static function validateLanguage()
233 {
234 return array(
235 new Main\Entity\Validator\Length(null, 50),
236 );
237 }
238
239 public static function onAfterUpdate(\Bitrix\Main\ORM\Event $event)
240 {
241 $id = (int)$event->getParameter('primary')['BOT_ID'];
242 $fields = $event->getParameter('fields');
243
244 if (static::needCacheInvalidate($fields))
245 {
247 }
248
249 return new Main\Entity\EventResult();
250 }
251
252 public static function onAfterDelete(Event $event)
253 {
254 $id = (int)$event->getParameter('primary')['BOT_ID'];
256
257 return new Main\Entity\EventResult();
258 }
259
260 protected static function needCacheInvalidate(array $updatedFields): bool
261 {
262 $cacheInvalidatingFields = [
263 'BOT_ID',
264 'MODULE_ID',
265 'CODE',
266 'TYPE',
267 'CLASS',
268 'LANG',
269 'METHOD_BOT_DELETE',
270 'METHOD_MESSAGE_ADD',
271 'METHOD_MESSAGE_UPDATE',
272 'METHOD_MESSAGE_DELETE',
273 'METHOD_CONTEXT_GET',
274 'METHOD_WELCOME_MESSAGE',
275 'TEXT_PRIVATE_WELCOME_MESSAGE',
276 'TEXT_CHAT_WELCOME_MESSAGE',
277 'APP_ID',
278 'VERIFIED',
279 'OPENLINE',
280 'HIDDEN',
281 'BACKGROUND_ID',
282 ];
283
284 return !empty(array_intersect($cacheInvalidatingFields, array_keys($updatedFields)));
285 }
286}
Определения bot.php:38
static validateToMethod()
Определения bot.php:196
static validateAppId()
Определения bot.php:208
static getMap()
Определения bot.php:55
static validateBotCode()
Определения bot.php:160
static validateLanguage()
Определения bot.php:232
static validateBotType()
Определения bot.php:220
static validateToClass()
Определения bot.php:172
static needCacheInvalidate(array $updatedFields)
Определения bot.php:260
static onAfterDelete(Event $event)
Определения bot.php:252
static onAfterUpdate(\Bitrix\Main\ORM\Event $event)
Определения bot.php:239
static validateModuleId()
Определения bot.php:184
static getTableName()
Определения bot.php:45
cleanCache()
Определения entity.php:1411
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения ufield.php:9
$event
Определения prolog_after.php:141
$fields
Определения yandex_run.php:501