Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
restprovider.php
1<?php
2namespace Bitrix\Bizproc;
3
5
36class RestProviderTable extends Entity\DataManager
37{
38 const TYPE_SMS = 'SMS';
39
45 public static function getTableName()
46 {
47 return 'b_bp_rest_provider';
48 }
49
55 public static function getMap()
56 {
57 return array(
58 'ID' => array(
59 'data_type' => 'integer',
60 'primary' => true,
61 'autocomplete' => true,
62 ),
63 'APP_ID' => array(
64 'data_type' => 'string',
65 'required' => true,
66 'validation' => array(__CLASS__, 'validateAppId'),
67 ),
68 'APP_NAME' => array(
69 'data_type' => 'text',
70 'required' => true,
71 'serialized' => true,
72 'save_data_modification' => array(__CLASS__, 'getLocalizationSaveModifiers'),
73 ),
74 'CODE' => array(
75 'data_type' => 'string',
76 'required' => true,
77 'validation' => array(__CLASS__, 'validateCode'),
78 ),
79 'TYPE' => array(
80 'data_type' => 'string',
81 'required' => true,
82 'validation' => array(__CLASS__, 'validateType'),
83 ),
84 'HANDLER' => array(
85 'data_type' => 'string',
86 'required' => true,
87 'validation' => array(__CLASS__, 'validateHandler'),
88 ),
89 'NAME' => array(
90 'data_type' => 'text',
91 'required' => true,
92 'serialized' => true,
93 'save_data_modification' => array(__CLASS__, 'getLocalizationSaveModifiers'),
94 ),
95 'DESCRIPTION' => array(
96 'data_type' => 'text',
97 'serialized' => true,
98 'save_data_modification' => array(__CLASS__, 'getLocalizationSaveModifiers'),
99 ),
100 );
101 }
102
108 public static function validateAppId()
109 {
110 return array(
111 new Entity\Validator\Length(null, 128),
112 );
113 }
114
120 public static function validateCode()
121 {
122 return array(
123 new Entity\Validator\Length(null, 128),
124 );
125 }
126
132 public static function validateType()
133 {
134 return array(
135 new Entity\Validator\Length(null, 30),
136 );
137 }
138
144 public static function validateHandler()
145 {
146 return array(
147 new Entity\Validator\Length(null, 1000),
148 );
149 }
150
154 public static function getLocalizationSaveModifiers()
155 {
156 return array(array(__CLASS__, 'prepareLocalization'));
157 }
158
163 public static function prepareLocalization($value)
164 {
165 if (!is_array($value))
166 $value = array('*' => (string) $value);
167 return $value;
168 }
169
175 public static function getLocalization($field, $langId)
176 {
177 $result = '';
178 $langId = mb_strtoupper($langId);
179 if (is_string($field))
180 $result = $field;
181 elseif (!empty($field[$langId]))
182 $result = $field[$langId];
183 elseif ($langId == 'UA' && !empty($field['RU']))
184 $result = $field['RU'];
185 elseif (!empty($field['EN']))
186 $result = $field['EN'];
187 elseif (!empty($field['*']))
188 $result = $field['*'];
189 return $result;
190 }
191
196 public static function getTypesList()
197 {
198 return array(static::TYPE_SMS);
199 }
200}
static getLocalization($field, $langId)