Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
restactivity.php
1<?php
2namespace Bitrix\Bizproc;
3
8
46class RestActivityTable extends Entity\DataManager
47{
53 public static function getFilePath()
54 {
55 return __FILE__;
56 }
57
63 public static function getTableName()
64 {
65 return 'b_bp_rest_activity';
66 }
67
73 public static function getMap()
74 {
75 return array(
76 'ID' => array(
77 'data_type' => 'integer',
78 'primary' => true,
79 'autocomplete' => true,
80 ),
81 'APP_ID' => array(
82 'data_type' => 'string',
83 'required' => true,
84 'validation' => array(__CLASS__, 'validateAppId'),
85 ),
86 'APP_NAME' => array(
87 'data_type' => 'text',
88 'required' => true,
89 'serialized' => true,
90 'save_data_modification' => array(__CLASS__, 'getLocalizationSaveModifiers'),
91 ),
92 'CODE' => array(
93 'data_type' => 'string',
94 'required' => true,
95 'validation' => array(__CLASS__, 'validateCode'),
96 ),
97 'INTERNAL_CODE' => array(
98 'data_type' => 'string',
99 'required' => true,
100 ),
101 'HANDLER' => array(
102 'data_type' => 'string',
103 'required' => true,
104 'validation' => array(__CLASS__, 'validateHandler'),
105 ),
106 'AUTH_USER_ID' => array(
107 'data_type' => 'integer',
108 'default_value' => 0
109 ),
110 'USE_SUBSCRIPTION' => array(
111 'data_type' => 'string'
112 ),
113 'USE_PLACEMENT' => array(
114 'data_type' => 'boolean',
115 'values' => ['N', 'Y']
116 ),
117 'NAME' => array(
118 'data_type' => 'text',
119 'required' => true,
120 'serialized' => true,
121 'save_data_modification' => array(__CLASS__, 'getLocalizationSaveModifiers'),
122 ),
123 'DESCRIPTION' => array(
124 'data_type' => 'text',
125 'serialized' => true,
126 'save_data_modification' => array(__CLASS__, 'getLocalizationSaveModifiers'),
127 ),
128 'PROPERTIES' => array(
129 'data_type' => 'text',
130 'serialized' => true,
131 'validation' => array(__CLASS__, 'validateProperties'),
132 ),
133 'RETURN_PROPERTIES' => array(
134 'data_type' => 'text',
135 'serialized' => true,
136 'validation' => array(__CLASS__, 'validateProperties'),
137 ),
138 'DOCUMENT_TYPE' => array(
139 'data_type' => 'text',
140 'serialized' => true,
141 ),
142 'FILTER' => array(
143 'data_type' => 'text',
144 'serialized' => true,
145 ),
146 'IS_ROBOT' => array(
147 'data_type' => 'boolean',
148 'values' => ['N', 'Y']
149 ),
150 );
151 }
152
158 public static function validateAppId()
159 {
160 return array(
161 new Entity\Validator\Length(null, 128),
162 );
163 }
164
170 public static function validateCode()
171 {
172 return array(
173 new Entity\Validator\Length(null, 128),
174 );
175 }
176
182 public static function validateHandler()
183 {
184 return array(
185 new Entity\Validator\Length(null, 1000),
186 );
187 }
188
192 public static function getLocalizationSaveModifiers()
193 {
194 return array(array(__CLASS__, 'prepareLocalization'));
195 }
196
202 public static function validateProperties()
203 {
204 return array(
205 function($value, $primary, $row, Field $field) {
206 $errorMsg = GetMessage("BPRAT_PROPERTIES_LENGTH_ERROR", array("#FIELD_TITLE#" => $field->getTitle()));
207 return BinaryString::getLength(serialize($value)) < 65535 ? true : $errorMsg;
208 }
209 );
210 }
211
216 public static function prepareLocalization($value)
217 {
218 if (!is_array($value))
219 $value = array('*' => (string) $value);
220 return $value;
221 }
222
228 public static function getLocalization($field, $langId)
229 {
230 $result = '';
231 $langId = mb_strtoupper($langId);
232 if (is_string($field))
233 $result = $field;
234 elseif (!empty($field[$langId]))
235 $result = $field[$langId];
236 elseif ($langId == 'UA' && !empty($field['RU']))
237 $result = $field['RU'];
238 elseif (!empty($field['EN']))
239 $result = $field['EN'];
240 elseif (!empty($field['*']))
241 $result = $field['*'];
242 return $result;
243 }
244}
static getLocalization($field, $langId)