Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
store.php
1<?php
2
3namespace Bitrix\Catalog;
4
8
54class StoreTable extends Main\Entity\DataManager
55{
61 public static function getTableName()
62 {
63 return 'b_catalog_store';
64 }
65
71 public static function getMap()
72 {
73 return [
74 'ID' => new Main\Entity\IntegerField(
75 'ID',
76 [
77 'primary' => true,
78 'autocomplete' => true,
79 'title' => Loc::getMessage('STORE_ENTITY_ID_FIELD'),
80 ]
81 ),
82 'TITLE' => new Main\Entity\StringField(
83 'TITLE',
84 [
85 'validation' => [__CLASS__, 'validateTitle'],
86 'title' => Loc::getMessage('STORE_ENTITY_TITLE_FIELD'),
87 ]
88 ),
89 'ACTIVE' => new Main\Entity\BooleanField(
90 'ACTIVE',
91 [
92 'values' => ['N', 'Y'],
93 'default_value' => 'Y',
94 'title' => Loc::getMessage('STORE_ENTITY_ACTIVE_FIELD'),
95 ]
96 ),
97 'ADDRESS' => new Main\Entity\StringField(
98 'ADDRESS',
99 [
100 'required' => true,
101 'validation' => [__CLASS__, 'validateAddress'],
102 'title' => Loc::getMessage('STORE_ENTITY_ADDRESS_FIELD'),
103 ]
104 ),
105 'DESCRIPTION' => new Main\Entity\TextField(
106 'DESCRIPTION',
107 [
108 'title' => Loc::getMessage('STORE_ENTITY_DESCRIPTION_FIELD'),
109 ]
110 ),
111 'GPS_N' => new Main\Entity\StringField(
112 'GPS_N',
113 [
114 'validation' => [__CLASS__, 'validateGpsN'],
115 'title' => Loc::getMessage('STORE_ENTITY_GPS_N_FIELD'),
116 ]
117 ),
118 'GPS_S' => new Main\Entity\StringField(
119 'GPS_S',
120 [
121 'validation' => [__CLASS__, 'validateGpsS'],
122 'title' => Loc::getMessage('STORE_ENTITY_GPS_S_FIELD'),
123 ]
124 ),
125 'IMAGE_ID' => new Main\Entity\StringField(
126 'IMAGE_ID',
127 [
128 'validation' => [__CLASS__, 'validateImageId'],
129 'title' => Loc::getMessage('STORE_ENTITY_IMAGE_ID_FIELD'),
130 ]
131 ),
132 'LOCATION_ID' => new Main\Entity\IntegerField(
133 'LOCATION_ID',
134 [
135 'title' => Loc::getMessage('STORE_ENTITY_LOCATION_ID_FIELD'),
136 ]
137 ),
138 'DATE_MODIFY' => new Main\Entity\DatetimeField(
139 'DATE_MODIFY',
140 [
141 'default_value' => function()
142 {
143 return new Main\Type\DateTime();
144 },
145 'title' => Loc::getMessage('STORE_ENTITY_DATE_MODIFY_FIELD'),
146 ]
147 ),
148 'DATE_CREATE' => new Main\Entity\DatetimeField(
149 'DATE_CREATE',
150 [
151 'default_value' => function()
152 {
153 return new Main\Type\DateTime();
154 },
155 'title' => Loc::getMessage('STORE_ENTITY_DATE_CREATE_FIELD'),
156 ]
157 ),
158 'USER_ID' => new Main\Entity\IntegerField(
159 'USER_ID',
160 [
161 'default_value' => null,
162 'title' => Loc::getMessage('STORE_ENTITY_USER_ID_FIELD'),
163 ]
164 ),
165 'CREATED_BY_USER' => new Main\ORM\Fields\Relations\Reference(
166 'CREATED_BY_USER',
167 UserTable::class,
168 Main\ORM\Query\Join::on('this.USER_ID', 'ref.ID')
169 ),
170 'MODIFIED_BY' => new Main\Entity\IntegerField(
171 'MODIFIED_BY',
172 [
173 'default_value' => null,
174 'title' => Loc::getMessage('STORE_ENTITY_MODIFIED_BY_FIELD'),
175 ]
176 ),
177 'MODIFIED_BY_USER' => new Main\ORM\Fields\Relations\Reference(
178 'MODIFIED_BY_USER',
179 UserTable::class,
180 Main\ORM\Query\Join::on('this.MODIFIED_BY', 'ref.ID')
181 ),
182 'PHONE' => new Main\Entity\StringField(
183 'PHONE',
184 [
185 'validation' => [__CLASS__, 'validatePhone'],
186 'title' => Loc::getMessage('STORE_ENTITY_PHONE_FIELD'),
187 ]
188 ),
189 'SCHEDULE' => new Main\Entity\StringField(
190 'SCHEDULE',
191 [
192 'validation' => [__CLASS__, 'validateSchedule'],
193 'title' => Loc::getMessage('STORE_ENTITY_SCHEDULE_FIELD'),
194 ]
195 ),
196 'XML_ID' => new Main\Entity\StringField(
197 'XML_ID',
198 [
199 'validation' => [__CLASS__, 'validateXmlId'],
200 'title' => Loc::getMessage('STORE_ENTITY_XML_ID_FIELD'),
201 ]
202 ),
203 'SORT' => new Main\Entity\IntegerField(
204 'SORT',
205 [
206 'default_value' => 100,
207 'title' => Loc::getMessage('STORE_ENTITY_SORT_FIELD'),
208 ]
209 ),
210 'EMAIL' => new Main\Entity\StringField(
211 'EMAIL',
212 [
213 'validation' => [__CLASS__, 'validateEmail'],
214 'title' => Loc::getMessage('STORE_ENTITY_EMAIL_FIELD'),
215 ]
216 ),
217 'ISSUING_CENTER' => new Main\Entity\BooleanField(
218 'ISSUING_CENTER',
219 [
220 'values' => ['N', 'Y'],
221 'default_value' => 'Y',
222 'title' => Loc::getMessage('STORE_ENTITY_ISSUING_CENTER_FIELD'),
223 ]
224 ),
225 'SHIPPING_CENTER' => new Main\Entity\BooleanField(
226 'SHIPPING_CENTER',
227 [
228 'values' => ['N', 'Y'],
229 'default_value' => 'Y',
230 'title' => Loc::getMessage('STORE_ENTITY_SHIPPING_CENTER_FIELD'),
231 ]
232 ),
233 'SITE_ID' => new Main\Entity\StringField(
234 'SITE_ID',
235 [
236 'validation' => [__CLASS__, 'validateSiteId'],
237 'title' => Loc::getMessage('STORE_ENTITY_SITE_ID_FIELD'),
238 ]
239 ),
240 'CODE' => new Main\Entity\StringField(
241 'CODE',
242 [
243 'validation' => [__CLASS__, 'validateCode'],
244 'title' => Loc::getMessage('STORE_ENTITY_CODE_FIELD'),
245 ]
246 ),
247 'IS_DEFAULT' => new Main\ORM\Fields\EnumField(
248 'IS_DEFAULT',
249 [
250 'values' => ['N', 'Y'],
251 'default_value' => 'N',
252 'title' => Loc::getMessage('STORE_ENTITY_IS_DEFAULT_FIELD'),
253 ]
254 ),
255 ];
256 }
257
263 public static function getUfId()
264 {
265 return 'CAT_STORE';
266 }
267
273 public static function validateTitle(): array
274 {
275 return [
276 new Main\Entity\Validator\Length(null, 75),
277 ];
278 }
279
285 public static function validateAddress(): array
286 {
287 return [
288 new Main\Entity\Validator\Length(null, 245),
289 ];
290 }
291
297 public static function validateGpsN(): array
298 {
299 return [
300 new Main\Entity\Validator\Length(null, 15),
301 ];
302 }
303
309 public static function validateGpsS(): array
310 {
311 return [
312 new Main\Entity\Validator\Length(null, 15),
313 ];
314 }
315
321 public static function validateImageId(): array
322 {
323 return [
324 new Main\Entity\Validator\Length(null, 45),
325 ];
326 }
327
333 public static function validatePhone(): array
334 {
335 return [
336 new Main\Entity\Validator\Length(null, 45),
337 ];
338 }
339
345 public static function validateSchedule(): array
346 {
347 return [
348 new Main\Entity\Validator\Length(null, 255),
349 ];
350 }
351
357 public static function validateXmlId(): array
358 {
359 return [
360 new Main\Entity\Validator\Length(null, 255),
361 ];
362 }
363
369 public static function validateEmail(): array
370 {
371 return [
372 new Main\Entity\Validator\Length(null, 255),
373 ];
374 }
375
381 public static function validateSiteId(): array
382 {
383 return [
384 new Main\Entity\Validator\Length(null, 2),
385 ];
386 }
387
393 public static function validateCode(): array
394 {
395 return [
396 new Main\Entity\Validator\Length(null, 255),
397 ];
398 }
399
400 public static function getDefaultStoreId(): ?int
401 {
402 $row = self::getRow([
403 'select' => [
404 'ID',
405 ],
406 'filter' => [
407 '=IS_DEFAULT' => 'Y',
408 ],
409 'cache' => ['ttl' => 86400],
410 ]);
411 $defaultStoreId = (int)($row['ID'] ?? 0);
412
413 return ($defaultStoreId > 0 ? $defaultStoreId : null);
414 }
415}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29