Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
integration.php
1<?php
2
3namespace Bitrix\Rest\Preset;
4
7use Bitrix\Main\Entity\ReferenceField;
8
9Loc::loadMessages(__FILE__);
10
49class IntegrationTable extends Main\Entity\DataManager
50{
56 public static function getTableName()
57 {
58 return 'b_rest_integration';
59 }
60
66 public static function getMap()
67 {
68 return array(
69 'ID' => array(
70 'data_type' => 'integer',
71 'primary' => true,
72 'autocomplete' => true,
73 'title' => Loc::getMessage('INTEGRATION_ENTITY_ID_FIELD'),
74 ),
75 'USER_ID' => array(
76 'data_type' => 'integer',
77 'validation' => array(__CLASS__, 'validateUser'),
78 'title' => Loc::getMessage('INTEGRATION_ENTITY_USER_ID_FIELD'),
79 ),
80 'ELEMENT_CODE' => array(
81 'data_type' => 'string',
82 'required' => true,
83 'validation' => array(__CLASS__, 'validateElementCode'),
84 'title' => Loc::getMessage('INTEGRATION_ENTITY_ELEMENT_CODE_FIELD'),
85 ),
86 'TITLE' => array(
87 'data_type' => 'string',
88 'required' => true,
89 'validation' => array(__CLASS__, 'validateTitle'),
90 'title' => Loc::getMessage('INTEGRATION_ENTITY_TITLE_FIELD'),
91 ),
92 'PASSWORD_ID' => array(
93 'data_type' => 'integer',
94 'validation' => array(__CLASS__, 'validatePassword'),
95 'title' => Loc::getMessage('INTEGRATION_ENTITY_PASSWORD_ID_FIELD'),
96 ),
97 'APP_ID' => array(
98 'data_type' => 'integer',
99 'validation' => array(__CLASS__, 'validateApp'),
100 'title' => Loc::getMessage('INTEGRATION_ENTITY_APP_ID_FIELD'),
101 ),
102 'SCOPE' => array(
103 'data_type' => 'text',
104 'save_data_modification' => function()
105 {
106 return array(
107 function($value)
108 {
109 return is_array($value) ? implode(',', $value) : '';
110 }
111 );
112 },
113 'fetch_data_modification' => function()
114 {
115 return array(
116 function($value)
117 {
118 return explode(',', $value);
119 }
120 );
121 },
122 'title' => Loc::getMessage('INTEGRATION_ENTITY_SCOPE_FIELD'),
123 ),
124 'QUERY' => array(
125 'data_type' => 'text',
126 'serialized' => true,
127 'title' => Loc::getMessage('INTEGRATION_ENTITY_QUERY_FIELD'),
128 ),
129 'OUTGOING_EVENTS' => array(
130 'data_type' => 'text',
131 'save_data_modification' => function()
132 {
133 return array(
134 function($value)
135 {
136 return is_array($value) ? implode(',', $value) : '';
137 }
138 );
139 },
140 'fetch_data_modification' => function()
141 {
142 return array(
143 function($value)
144 {
145 return explode(',', $value);
146 }
147 );
148 },
149 'title' => Loc::getMessage('INTEGRATION_ENTITY_OUTGOING_EVENTS_FIELD'),
150 ),
151 'OUTGOING_NEEDED' => array(
152 'data_type' => 'string',
153 'validation' => array(__CLASS__, 'validateOutgoingQueryNeeded'),
154 'title' => Loc::getMessage('INTEGRATION_ENTITY_OUTGOING_NEEDED_FIELD'),
155 ),
156 'OUTGOING_HANDLER_URL' => array(
157 'data_type' => 'string',
158 'validation' => array(__CLASS__, 'validateOutgoingHandlerUrl'),
159 'title' => Loc::getMessage('INTEGRATION_ENTITY_OUTGOING_HANDLER_URL_FIELD'),
160 ),
161 'WIDGET_NEEDED' => array(
162 'data_type' => 'string',
163 'validation' => array(__CLASS__, 'validateWidgetNeeded'),
164 'title' => Loc::getMessage('INTEGRATION_ENTITY_WIDGET_NEEDED_FIELD'),
165 ),
166 'WIDGET_HANDLER_URL' => array(
167 'data_type' => 'string',
168 'validation' => array(__CLASS__, 'validateWidgetHandlerUrl'),
169 'title' => Loc::getMessage('INTEGRATION_ENTITY_WIDGET_HANDLER_URL_FIELD'),
170 ),
171 'WIDGET_LIST' => array(
172 'data_type' => 'text',
173 'save_data_modification' => function()
174 {
175 return array(
176 function($value)
177 {
178 return is_array($value) ? implode(',', $value) : '';
179 }
180 );
181 },
182 'fetch_data_modification' => function()
183 {
184 return array(
185 function($value)
186 {
187 return explode(',', $value);
188 }
189 );
190 },
191 'title' => Loc::getMessage('INTEGRATION_ENTITY_WIDGET_LIST_FIELD'),
192 ),
193 'APPLICATION_TOKEN' => array(
194 'data_type' => 'string',
195 'validation' => array(__CLASS__, 'validateApplicationToken'),
196 'title' => Loc::getMessage('INTEGRATION_ENTITY_APPLICATION_TOKEN_FIELD'),
197 ),
198 'APPLICATION_NEEDED' => array(
199 'data_type' => 'string',
200 'validation' => array(__CLASS__, 'validateApplicationNeeded'),
201 'title' => Loc::getMessage('INTEGRATION_ENTITY_APPLICATION_NEEDED_FIELD'),
202 ),
203 'APPLICATION_ONLY_API' => array(
204 'data_type' => 'string',
205 'validation' => array(__CLASS__, 'validateApplicationOnlyApi'),
206 'title' => Loc::getMessage('INTEGRATION_ENTITY_APPLICATION_ONLY_API_FIELD'),
207 ),
208 'BOT_ID' => array(
209 'data_type' => 'integer',
210 'title' => Loc::getMessage('INTEGRATION_ENTITY_BOT_ID_FIELD'),
211 ),
212 'BOT_HANDLER_URL' => array(
213 'data_type' => 'string',
214 'validation' => array(__CLASS__, 'validateBotHandlerUrl'),
215 'title' => Loc::getMessage('INTEGRATION_ENTITY_BOT_HANDLER_URL_FIELD'),
216 ),
217 'USER' => new ReferenceField(
218 'USER',
219 '\Bitrix\Main\UserTable',
220 array('=this.USER_ID' => 'ref.ID')
221 ),
222 );
223 }
224
230 public static function validateUser()
231 {
232 return array(
233 new Main\Entity\Validator\Length(null, 11),
234 );
235 }
236
242 public static function validateElementCode()
243 {
244 return array(
245 new Main\Entity\Validator\Length(null, 256),
246 );
247 }
248
254 public static function validateTitle()
255 {
256 return array(
257 new Main\Entity\Validator\Length(null, 256),
258 );
259 }
260
266 public static function validatePassword()
267 {
268 return array(
269 new Main\Entity\Validator\Length(null, 11),
270 );
271 }
272
278 public static function validateApp()
279 {
280 return array(
281 new Main\Entity\Validator\Length(null, 11),
282 );
283 }
284
290 public static function validateOutgoingQueryNeeded()
291 {
292 return array(
293 new Main\Entity\Validator\Length(null, 1),
294 );
295 }
301 public static function validateOutgoingHandlerUrl()
302 {
303 return array(
304 new Main\Entity\Validator\Length(null, 2048),
305 );
306 }
307
313 public static function validateWidgetNeeded()
314 {
315 return array(
316 new Main\Entity\Validator\Length(null, 1),
317 );
318 }
319
325 public static function validateWidgetHandlerUrl()
326 {
327 return array(
328 new Main\Entity\Validator\Length(null, 2048),
329 );
330 }
331
337 public static function validateApplicationToken()
338 {
339 return array(
340 new Main\Entity\Validator\Length(null, 50),
341 );
342 }
343
349 public static function validateApplicationNeeded()
350 {
351 return array(
352 new Main\Entity\Validator\Length(null, 1),
353 );
354 }
360 public static function validateApplicationOnlyApi()
361 {
362 return array(
363 new Main\Entity\Validator\Length(null, 1),
364 );
365 }
366
372 public static function validateBotHandlerUrl()
373 {
374 return array(
375 new Main\Entity\Validator\Length(null, 2048),
376 );
377 }
378}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29