1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
property.php
См. документацию.
1
<?php
2
3
4
namespace
Bitrix\Sale\Rest\Entity;
5
6
7
use Bitrix\Main\Engine\Response\Converter;
8
use Bitrix\Sale\Rest\Attributes;
9
10
class
Property
extends
Base
11
{
12
const
PROPERTY_TYPE_STRING
=
'STRING'
;
13
const
PROPERTY_TYPE_YN
=
'Y/N'
;
14
const
PROPERTY_TYPE_NUMBER
=
'NUMBER'
;
15
const
PROPERTY_TYPE_ENUM
=
'ENUM'
;
16
const
PROPERTY_TYPE_FILE
=
'FILE'
;
17
const
PROPERTY_TYPE_DATE
=
'DATE'
;
18
const
PROPERTY_TYPE_LOCATION
=
'LOCATION'
;
19
const
PROPERTY_TYPE_ADDRESS
=
'ADDRESS'
;
20
21
public
function
prepareFieldInfos
(
$fields
)
22
{
23
$fieldsInfo = parent::prepareFieldInfos(
$fields
);
24
25
foreach
(
$fields
as
$name
=>
$info
)
26
{
27
if
(
$name
==
'SETTINGS'
)
28
{
29
$fieldsInfo[
$name
][
'FIELDS'
] = parent::prepareFieldInfos(
$info
[
'FIELDS'
]);
30
}
31
}
32
return
$fieldsInfo;
33
}
34
35
public
function
getFields
()
36
{
37
return
array_merge(
38
[
39
'ID'
=>[
40
'TYPE'
=>self::TYPE_INT,
41
'ATTRIBUTES'
=>[
Attributes::ReadOnly
]
42
],
43
'PERSON_TYPE_ID'
=>[
44
'TYPE'
=>self::TYPE_INT,
45
'ATTRIBUTES'
=>[
46
Attributes::Required
,
47
Attributes::Immutable
48
]
49
],
50
'PROPS_GROUP_ID'
=>[
51
'TYPE'
=>self::TYPE_INT,
52
'ATTRIBUTES'
=>[
53
Attributes::Required
,
54
Attributes::Immutable
55
]
56
],
57
'NAME'
=>[
58
'TYPE'
=>self::TYPE_STRING,
59
'ATTRIBUTES'
=>[
Attributes::Required
]
60
],
61
'CODE'
=>[
62
'TYPE'
=>self::TYPE_STRING
63
],
64
'ACTIVE'
=>[
65
'TYPE'
=>self::TYPE_CHAR
66
],
67
'UTIL'
=>[
68
'TYPE'
=>self::TYPE_CHAR
69
],
70
'USER_PROPS'
=>[
71
'TYPE'
=>self::TYPE_CHAR
72
],
73
'IS_FILTERED'
=>[
74
'TYPE'
=>self::TYPE_CHAR
75
],
76
'SORT'
=>[
77
'TYPE'
=>self::TYPE_INT
78
],
79
'DESCRIPTION'
=>[
80
'TYPE'
=>self::TYPE_STRING
81
],
82
'XML_ID'
=>[
83
'TYPE'
=>self::TYPE_STRING
84
],
85
'TYPE'
=>[
86
'TYPE'
=>self::TYPE_STRING,
87
'ATTRIBUTES'
=>[
88
Attributes::Required
,
89
Attributes::Immutable
90
]
91
],
92
'REQUIRED'
=>[
93
'TYPE'
=>self::TYPE_CHAR
94
],
95
'MULTIPLE'
=>[
96
'TYPE'
=>self::TYPE_CHAR
97
],
98
'DEFAULT_VALUE'
=>[
99
'TYPE'
=>self::TYPE_STRING
100
],
101
'SETTINGS'
=>[
102
'TYPE'
=>self::TYPE_DATATYPE,
103
//'ATTRIBUTES'=>[Attributes::ReadOnly]
104
],
105
],
106
$this->
getFieldsByTypeString
(),
107
$this->
getFieldsByTypeLocation
(),
108
$this->
getFieldsByTypeAddress
()
109
);
110
}
111
112
public
function
getFieldsByType
(
$type
)
113
{
114
$filterMap = [
115
self::PROPERTY_TYPE_STRING =>
function
(
$k
)
116
{
117
return
(
118
is_set
($this->
getFieldsByTypeLocation
(),
$k
) ===
false
119
&&
is_set
($this->
getFieldsByTypeAddress
(),
$k
) ===
false
120
);
121
},
122
self::PROPERTY_TYPE_LOCATION =>
function
(
$k
)
123
{
124
return
(
125
is_set
($this->
getFieldsByTypeString
(),
$k
) ===
false
126
&&
is_set
($this->
getFieldsByTypeAddress
(),
$k
) ===
false
127
);
128
},
129
self::PROPERTY_TYPE_ADDRESS =>
function
(
$k
)
130
{
131
return
(
132
is_set
($this->
getFieldsByTypeString
(),
$k
) ===
false
133
&&
is_set
($this->
getFieldsByTypeLocation
(),
$k
) ===
false
134
);
135
},
136
'DEFAULT'
=>
function
(
$k
)
137
{
138
return
(
139
is_set
($this->
getFieldsByTypeString
(),
$k
) ===
false
140
&&
is_set
($this->
getFieldsByTypeLocation
(),
$k
) ===
false
141
&&
is_set
($this->
getFieldsByTypeAddress
(),
$k
) ===
false
142
);
143
},
144
];
145
146
$filter
= isset($filterMap[
$type
]) ? $filterMap[
$type
] : $filterMap[
'DEFAULT'
];
147
148
$r = array_filter($this->
getFields
(),
$filter
, ARRAY_FILTER_USE_KEY);
149
150
$r[
'SETTINGS'
][
'FIELDS'
] = $this->
getFieldsSettingsByType
($type);
151
152
return
$r;
153
}
154
155
protected
function
getFieldsSettingsByType
(
$type
)
156
{
157
$r = [];
158
159
if
(
$type
== self::PROPERTY_TYPE_STRING)
160
{
161
$r = $this->
getFieldsSettingsByTypeString
();
162
}
163
elseif
(
$type
== self::PROPERTY_TYPE_YN)
164
{
165
$r = $this->
getFieldsSettingsByEitherYNType
();
166
}
167
elseif
(
$type
== self::PROPERTY_TYPE_NUMBER)
168
{
169
$r = $this->
getFieldsSettingsByNumberType
();
170
}
171
elseif
(
$type
== self::PROPERTY_TYPE_ENUM)
172
{
173
$r = $this->
getFieldsSettingsByEnumType
();
174
}
175
elseif
(
$type
== self::PROPERTY_TYPE_FILE)
176
{
177
$r = $this->
getFieldsSettingsByFileType
();
178
}
179
elseif
(
$type
== self::PROPERTY_TYPE_DATE)
180
{
181
$r = $this->
getFieldsSettingsByDateType
();
182
}
183
elseif
(
$type
== self::PROPERTY_TYPE_LOCATION)
184
{
185
$r = $this->
getFieldsSettingsByLocation
();
186
}
187
188
return
$r;
189
}
190
191
protected
function
getFieldsByTypeString
()
192
{
193
return
[
194
'IS_PROFILE_NAME'
=>[
195
'TYPE'
=>self::TYPE_CHAR
196
],
197
'IS_PAYER'
=>[
198
'TYPE'
=>self::TYPE_CHAR
199
],
200
'IS_EMAIL'
=>[
201
'TYPE'
=>self::TYPE_CHAR
202
],
203
'IS_PHONE'
=>[
204
'TYPE'
=>self::TYPE_CHAR
205
],
206
'IS_ZIP'
=>[
207
'TYPE'
=>self::TYPE_CHAR
208
],
209
'IS_ADDRESS'
=>[
210
'TYPE'
=>self::TYPE_CHAR
211
],
212
];
213
}
214
215
protected
function
getFieldsByTypeAddress
()
216
{
217
return
[
218
'IS_ADDRESS_FROM'
=>[
219
'TYPE'
=>self::TYPE_CHAR
220
],
221
'IS_ADDRESS_TO'
=>[
222
'TYPE'
=>self::TYPE_CHAR
223
],
224
];
225
}
226
227
protected
function
getFieldsByTypeLocation
()
228
{
229
$r = [
230
'IS_LOCATION'
=>[
231
'TYPE'
=>self::TYPE_CHAR
232
],
233
'INPUT_FIELD_LOCATION'
=>[
234
'TYPE'
=>self::TYPE_STRING
// enum
235
],
236
'IS_LOCATION4TAX'
=>[
237
'TYPE'
=>self::TYPE_CHAR
238
]
239
];
240
return
$r;
241
}
242
243
protected
function
getFieldsSettingsByTypeString
()
244
{
245
return
[
246
'MINLENGTH'
=>[
247
'TYPE'
=>self::TYPE_INT,
248
],
249
'MAXLENGTH'
=>[
250
'TYPE'
=>self::TYPE_INT,
251
],
252
'PATTERN'
=>[
253
'TYPE'
=>self::TYPE_STRING,
254
],
255
'MULTILINE'
=>[
256
'TYPE'
=>self::TYPE_CHAR,
257
],
258
'COLS'
=>[
259
'TYPE'
=>self::TYPE_INT,
260
],
261
'ROWS'
=>[
262
'TYPE'
=>self::TYPE_INT,
263
],
264
'SIZE'
=>[
265
'TYPE'
=>self::TYPE_INT,
266
],
267
];
268
}
269
270
protected
function
getFieldsSettingsByEitherYNType
()
271
{
272
return
[];
273
}
274
275
protected
function
getFieldsSettingsByNumberType
()
276
{
277
return
[
278
'MIN'
=>[
279
'TYPE'
=>self::TYPE_INT,
280
],
281
'MAX'
=>[
282
'TYPE'
=>self::TYPE_INT,
283
],
284
'STEP'
=>[
285
'TYPE'
=>self::TYPE_INT,
286
]
287
];
288
}
289
290
protected
function
getFieldsSettingsByEnumType
()
291
{
292
return
[
293
'MULTIELEMENT'
=>[
294
'TYPE'
=>self::TYPE_CHAR,
295
],
296
'SIZE'
=>[
297
'TYPE'
=>self::TYPE_INT,
298
]
299
];
300
}
301
302
protected
function
getFieldsSettingsByFileType
()
303
{
304
return
[
305
'MAXSIZE'
=>[
306
'TYPE'
=>self::TYPE_INT,
307
],
308
'ACCEPT'
=>[
309
'TYPE'
=>self::TYPE_STRING,
310
]
311
];
312
}
313
314
protected
function
getFieldsSettingsByDateType
()
315
{
316
return
[
317
'TIME'
=>[
318
'TYPE'
=>self::TYPE_CHAR,
319
]
320
];
321
}
322
323
protected
function
getFieldsSettingsByLocation
()
324
{
325
return
[];
326
}
327
328
public
function
convertKeysToSnakeCaseArguments
(
$name
, $arguments)
329
{
330
if
(
$name
==
'getfieldssettingsbytype'
331
||
$name
==
'getfieldsbytype'
332
){
333
if
(isset($arguments[
'type'
]))
334
{
335
$fields
= $arguments[
'type'
];
336
if
(!empty(
$fields
))
337
{
338
$converter =
new
Converter
(Converter::VALUES | Converter::TO_UPPER);
339
$arguments[
'type'
] = $converter->process(
$fields
);
340
}
341
}
342
}
343
344
return
$arguments;
345
}
346
347
public
function
internalizeArguments
(
$name
, $arguments)
348
{
349
if
(
$name
==
'getfieldssettingsbytype'
350
||
$name
==
'getfieldsbytype'
351
){}
352
else
353
{
354
parent::internalizeArguments(
$name
, $arguments);
355
}
356
357
return
$arguments;
358
}
359
360
public
function
externalizeResult
(
$name
,
$fields
)
361
{
362
if
(
$name
==
'getfieldssettingsbytype'
363
||
$name
==
'getfieldsbytype'
364
){}
365
else
366
{
367
parent::externalizeResult(
$name
,
$fields
);
368
}
369
return
$fields
;
370
}
371
}
$type
$type
Определения
options.php:106
Bitrix\Main\Engine\Response\Converter
Определения
converter.php:8
Bitrix\Sale\Rest\Attributes\Required
const Required
Определения
attributes.php:11
Bitrix\Sale\Rest\Attributes\ReadOnly
const ReadOnly
Определения
attributes.php:9
Bitrix\Sale\Rest\Attributes\Immutable
const Immutable
Определения
attributes.php:10
Bitrix\Sale\Rest\Entity\Base
Определения
base.php:15
Bitrix\Sale\Rest\Entity\Property
Определения
property.php:11
Bitrix\Sale\Rest\Entity\Property\getFieldsSettingsByDateType
getFieldsSettingsByDateType()
Определения
property.php:314
Bitrix\Sale\Rest\Entity\Property\getFieldsByTypeLocation
getFieldsByTypeLocation()
Определения
property.php:227
Bitrix\Sale\Rest\Entity\Property\PROPERTY_TYPE_ENUM
const PROPERTY_TYPE_ENUM
Определения
property.php:15
Bitrix\Sale\Rest\Entity\Property\getFieldsSettingsByEnumType
getFieldsSettingsByEnumType()
Определения
property.php:290
Bitrix\Sale\Rest\Entity\Property\PROPERTY_TYPE_FILE
const PROPERTY_TYPE_FILE
Определения
property.php:16
Bitrix\Sale\Rest\Entity\Property\getFieldsSettingsByLocation
getFieldsSettingsByLocation()
Определения
property.php:323
Bitrix\Sale\Rest\Entity\Property\getFieldsByType
getFieldsByType($type)
Определения
property.php:112
Bitrix\Sale\Rest\Entity\Property\getFieldsSettingsByNumberType
getFieldsSettingsByNumberType()
Определения
property.php:275
Bitrix\Sale\Rest\Entity\Property\internalizeArguments
internalizeArguments($name, $arguments)
Определения
property.php:347
Bitrix\Sale\Rest\Entity\Property\getFieldsSettingsByType
getFieldsSettingsByType($type)
Определения
property.php:155
Bitrix\Sale\Rest\Entity\Property\getFieldsByTypeString
getFieldsByTypeString()
Определения
property.php:191
Bitrix\Sale\Rest\Entity\Property\convertKeysToSnakeCaseArguments
convertKeysToSnakeCaseArguments($name, $arguments)
Определения
property.php:328
Bitrix\Sale\Rest\Entity\Property\prepareFieldInfos
prepareFieldInfos($fields)
Определения
property.php:21
Bitrix\Sale\Rest\Entity\Property\getFieldsSettingsByEitherYNType
getFieldsSettingsByEitherYNType()
Определения
property.php:270
Bitrix\Sale\Rest\Entity\Property\getFieldsByTypeAddress
getFieldsByTypeAddress()
Определения
property.php:215
Bitrix\Sale\Rest\Entity\Property\PROPERTY_TYPE_YN
const PROPERTY_TYPE_YN
Определения
property.php:13
Bitrix\Sale\Rest\Entity\Property\PROPERTY_TYPE_NUMBER
const PROPERTY_TYPE_NUMBER
Определения
property.php:14
Bitrix\Sale\Rest\Entity\Property\PROPERTY_TYPE_STRING
const PROPERTY_TYPE_STRING
Определения
property.php:12
Bitrix\Sale\Rest\Entity\Property\getFieldsSettingsByTypeString
getFieldsSettingsByTypeString()
Определения
property.php:243
Bitrix\Sale\Rest\Entity\Property\PROPERTY_TYPE_ADDRESS
const PROPERTY_TYPE_ADDRESS
Определения
property.php:19
Bitrix\Sale\Rest\Entity\Property\externalizeResult
externalizeResult($name, $fields)
Определения
property.php:360
Bitrix\Sale\Rest\Entity\Property\getFieldsSettingsByFileType
getFieldsSettingsByFileType()
Определения
property.php:302
Bitrix\Sale\Rest\Entity\Property\PROPERTY_TYPE_DATE
const PROPERTY_TYPE_DATE
Определения
property.php:17
Bitrix\Sale\Rest\Entity\Property\PROPERTY_TYPE_LOCATION
const PROPERTY_TYPE_LOCATION
Определения
property.php:18
Bitrix\Sale\Rest\Entity\Property\getFields
getFields()
Определения
property.php:35
$filter
$filter
Определения
iblock_catalog_list.php:54
$info
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения
backup.php:924
is_set
is_set($a, $k=false)
Определения
tools.php:2133
$name
$name
Определения
menu_edit.php:35
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$k
$k
Определения
template_pdf.php:567
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
sale
lib
rest
entity
property.php
Создано системой
1.14.0