1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
integration.php
См. документацию.
1<?php
2
3namespace Bitrix\Rest\Preset;
4
5use Bitrix\Main;
6use Bitrix\Main\Localization\Loc;
7use Bitrix\Main\Entity\ReferenceField;
8use Bitrix\Main\ORM\Query\Join;
9use Bitrix\Rest\APAuth\PasswordTable;
10
11Loc::loadMessages(__FILE__);
12
50
51class IntegrationTable extends Main\Entity\DataManager
52{
58 public static function getTableName()
59 {
60 return 'b_rest_integration';
61 }
62
68 public static function getMap()
69 {
70 return array(
71 'ID' => array(
72 'data_type' => 'integer',
73 'primary' => true,
74 'autocomplete' => true,
75 'title' => Loc::getMessage('INTEGRATION_ENTITY_ID_FIELD'),
76 ),
77 'USER_ID' => array(
78 'data_type' => 'integer',
79 'validation' => array(__CLASS__, 'validateUser'),
80 'title' => Loc::getMessage('INTEGRATION_ENTITY_USER_ID_FIELD'),
81 ),
82 'ELEMENT_CODE' => array(
83 'data_type' => 'string',
84 'required' => true,
85 'validation' => array(__CLASS__, 'validateElementCode'),
86 'title' => Loc::getMessage('INTEGRATION_ENTITY_ELEMENT_CODE_FIELD'),
87 ),
88 'TITLE' => array(
89 'data_type' => 'string',
90 'required' => true,
91 'validation' => array(__CLASS__, 'validateTitle'),
92 'title' => Loc::getMessage('INTEGRATION_ENTITY_TITLE_FIELD'),
93 ),
94 'PASSWORD_ID' => array(
95 'data_type' => 'integer',
96 'validation' => array(__CLASS__, 'validatePassword'),
97 'title' => Loc::getMessage('INTEGRATION_ENTITY_PASSWORD_ID_FIELD'),
98 ),
99 'APP_ID' => array(
100 'data_type' => 'integer',
101 'validation' => array(__CLASS__, 'validateApp'),
102 'title' => Loc::getMessage('INTEGRATION_ENTITY_APP_ID_FIELD'),
103 ),
104 'SCOPE' => array(
105 'data_type' => 'text',
106 'save_data_modification' => function()
107 {
108 return array(
109 function($value)
110 {
111 return is_array($value) ? implode(',', $value) : '';
112 }
113 );
114 },
115 'fetch_data_modification' => function()
116 {
117 return array(
118 function($value)
119 {
120 return explode(',', $value);
121 }
122 );
123 },
124 'title' => Loc::getMessage('INTEGRATION_ENTITY_SCOPE_FIELD'),
125 ),
126 'QUERY' => array(
127 'data_type' => 'text',
128 'serialized' => true,
129 'title' => Loc::getMessage('INTEGRATION_ENTITY_QUERY_FIELD'),
130 ),
131 'OUTGOING_EVENTS' => array(
132 'data_type' => 'text',
133 'save_data_modification' => function()
134 {
135 return array(
136 function($value)
137 {
138 return is_array($value) ? implode(',', $value) : '';
139 }
140 );
141 },
142 'fetch_data_modification' => function()
143 {
144 return array(
145 function($value)
146 {
147 return explode(',', $value);
148 }
149 );
150 },
151 'title' => Loc::getMessage('INTEGRATION_ENTITY_OUTGOING_EVENTS_FIELD'),
152 ),
153 'OUTGOING_NEEDED' => array(
154 'data_type' => 'string',
155 'validation' => array(__CLASS__, 'validateOutgoingQueryNeeded'),
156 'title' => Loc::getMessage('INTEGRATION_ENTITY_OUTGOING_NEEDED_FIELD'),
157 ),
158 'OUTGOING_HANDLER_URL' => array(
159 'data_type' => 'string',
160 'validation' => array(__CLASS__, 'validateOutgoingHandlerUrl'),
161 'title' => Loc::getMessage('INTEGRATION_ENTITY_OUTGOING_HANDLER_URL_FIELD'),
162 ),
163 'WIDGET_NEEDED' => array(
164 'data_type' => 'string',
165 'validation' => array(__CLASS__, 'validateWidgetNeeded'),
166 'title' => Loc::getMessage('INTEGRATION_ENTITY_WIDGET_NEEDED_FIELD'),
167 ),
168 'WIDGET_HANDLER_URL' => array(
169 'data_type' => 'string',
170 'validation' => array(__CLASS__, 'validateWidgetHandlerUrl'),
171 'title' => Loc::getMessage('INTEGRATION_ENTITY_WIDGET_HANDLER_URL_FIELD'),
172 ),
173 'WIDGET_LIST' => array(
174 'data_type' => 'text',
175 'save_data_modification' => function()
176 {
177 return array(
178 function($value)
179 {
180 return is_array($value) ? implode(',', $value) : '';
181 }
182 );
183 },
184 'fetch_data_modification' => function()
185 {
186 return array(
187 function($value)
188 {
189 return explode(',', $value);
190 }
191 );
192 },
193 'title' => Loc::getMessage('INTEGRATION_ENTITY_WIDGET_LIST_FIELD'),
194 ),
195 'APPLICATION_TOKEN' => array(
196 'data_type' => 'string',
197 'validation' => array(__CLASS__, 'validateApplicationToken'),
198 'title' => Loc::getMessage('INTEGRATION_ENTITY_APPLICATION_TOKEN_FIELD'),
199 ),
200 'APPLICATION_NEEDED' => array(
201 'data_type' => 'string',
202 'validation' => array(__CLASS__, 'validateApplicationNeeded'),
203 'title' => Loc::getMessage('INTEGRATION_ENTITY_APPLICATION_NEEDED_FIELD'),
204 ),
205 'APPLICATION_ONLY_API' => array(
206 'data_type' => 'string',
207 'validation' => array(__CLASS__, 'validateApplicationOnlyApi'),
208 'title' => Loc::getMessage('INTEGRATION_ENTITY_APPLICATION_ONLY_API_FIELD'),
209 ),
210 'BOT_ID' => array(
211 'data_type' => 'integer',
212 'title' => Loc::getMessage('INTEGRATION_ENTITY_BOT_ID_FIELD'),
213 ),
214 'BOT_HANDLER_URL' => array(
215 'data_type' => 'string',
216 'validation' => array(__CLASS__, 'validateBotHandlerUrl'),
217 'title' => Loc::getMessage('INTEGRATION_ENTITY_BOT_HANDLER_URL_FIELD'),
218 ),
219 'USER' => new ReferenceField(
220 'USER',
221 '\Bitrix\Main\UserTable',
222 array('=this.USER_ID' => 'ref.ID')
223 ),
224 'PASSWORD' => new ReferenceField('PASSWORD',
225 PasswordTable::class,
226 Join::on('this.PASSWORD_ID', 'ref.ID')
227 )
228 );
229 }
230
236 public static function validateUser()
237 {
238 return array(
239 new Main\Entity\Validator\Length(null, 11),
240 );
241 }
242
248 public static function validateElementCode()
249 {
250 return array(
251 new Main\Entity\Validator\Length(null, 256),
252 );
253 }
254
260 public static function validateTitle()
261 {
262 return array(
263 new Main\Entity\Validator\Length(null, 256),
264 );
265 }
266
272 public static function validatePassword()
273 {
274 return array(
275 new Main\Entity\Validator\Length(null, 11),
276 );
277 }
278
284 public static function validateApp()
285 {
286 return array(
287 new Main\Entity\Validator\Length(null, 11),
288 );
289 }
290
296 public static function validateOutgoingQueryNeeded()
297 {
298 return array(
299 new Main\Entity\Validator\Length(null, 1),
300 );
301 }
302
307 public static function validateOutgoingHandlerUrl()
308 {
309 return array(
310 new Main\Entity\Validator\Length(null, 2048),
311 );
312 }
313
319 public static function validateWidgetNeeded()
320 {
321 return array(
322 new Main\Entity\Validator\Length(null, 1),
323 );
324 }
325
331 public static function validateWidgetHandlerUrl()
332 {
333 return array(
334 new Main\Entity\Validator\Length(null, 2048),
335 );
336 }
337
343 public static function validateApplicationToken()
344 {
345 return array(
346 new Main\Entity\Validator\Length(null, 50),
347 );
348 }
349
355 public static function validateApplicationNeeded()
356 {
357 return array(
358 new Main\Entity\Validator\Length(null, 1),
359 );
360 }
361
366 public static function validateApplicationOnlyApi()
367 {
368 return array(
369 new Main\Entity\Validator\Length(null, 1),
370 );
371 }
372
378 public static function validateBotHandlerUrl()
379 {
380 return array(
381 new Main\Entity\Validator\Length(null, 2048),
382 );
383 }
384
385 public static function onAfterUpdate(Main\Entity\Event $event): void
386 {
387 Main\Application::getInstance()->getCache()->cleanDir('rest/market_subscription');
388 }
389
390 public static function onAfterDelete(Main\Entity\Event $event): void
391 {
392 Main\Application::getInstance()->getCache()->cleanDir('rest/market_subscription');
393 }
394
395 public static function onAfterAdd(Main\Entity\Event $event): void
396 {
397 Main\Application::getInstance()->getCache()->cleanDir('rest/market_subscription');
398 }
399}
static getInstance()
Определения application.php:98
Определения event.php:5
static validateWidgetHandlerUrl()
Определения integration.php:331
static validateApplicationNeeded()
Определения integration.php:355
static validateApplicationToken()
Определения integration.php:343
static onAfterDelete(Main\Entity\Event $event)
Определения integration.php:390
static validateApplicationOnlyApi()
Определения integration.php:366
static validateWidgetNeeded()
Определения integration.php:319
static onAfterUpdate(Main\Entity\Event $event)
Определения integration.php:385
static onAfterAdd(Main\Entity\Event $event)
Определения integration.php:395
static validateOutgoingQueryNeeded()
Определения integration.php:296
static validatePassword()
Определения integration.php:272
static validateOutgoingHandlerUrl()
Определения integration.php:307
static getTableName()
Определения integration.php:58
static validateBotHandlerUrl()
Определения integration.php:378
static validateElementCode()
Определения integration.php:248
</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