32 if (is_array($fields))
34 foreach($fields as $name => $info)
36 $attributs = isset($info[
'ATTRIBUTES']) ? $info[
'ATTRIBUTES'] : [];
43 $result[$name] = array(
44 'TYPE' => $info[
'TYPE'],
66 $filter = is_set($params,
'filter')?$params[
'filter']:[];
67 $ignoredAttributes = is_set($filter,
'ignoredAttributes')?$filter[
'ignoredAttributes']:[];
68 $ignoredFields = is_set($filter,
'ignoredFields')?$filter[
'ignoredFields']:[];
69 $skipFields = is_set($filter,
'skipFields')?$filter[
'skipFields']:[];
71 foreach ($fieldsInfo as $name=>$info)
73 if(in_array($name, $ignoredFields))
77 elseif(in_array($name, $skipFields) ==
false)
79 if(isset($info[
'ATTRIBUTES']))
81 $skipAttr = array_intersect($ignoredAttributes, $info[
'ATTRIBUTES']);
97 return (isset($fields[
'ID']) ===
false);
108 $converter =
new Converter(Converter::VALUES | Converter::TO_SNAKE | Converter::TO_UPPER| Converter::TO_SNAKE_DIGIT);
109 $items = $converter->process($fields);
110 return $this->converterValuesProcessOnAfter($items);
122 $converter =
new Converter(Converter::VALUES | Converter::TO_UPPER);
123 $converterForKey =
new Converter(Converter::KEYS | Converter::TO_SNAKE | Converter::TO_UPPER | Converter::TO_SNAKE_DIGIT);
125 foreach ($converter->process($fields) as $key=>$value)
127 $result[$converterForKey->process($key)] = $value;
129 return $this->converterKeysProcessOnAfter($result);
139 $converter =
new Converter(Converter::KEYS | Converter::RECURSIVE | Converter::TO_SNAKE | Converter::TO_UPPER | Converter::TO_SNAKE_DIGIT);
140 $items = $converter->process($data);
141 return $this->converterKeysProcessOnAfter($items);
144 private function converterKeysProcessOnAfter($items): array
147 foreach ($items as $key=>$item)
149 $result[$this->resolveFieldName($key)] = $item;
154 private function converterValuesProcessOnAfter($items): array
157 foreach ($items as $key=>$item)
159 $result[$key] = $this->resolveFieldName($item);
164 private function resolveFieldName($name)
166 return ($name ===
'ID_1_C') ?
'ID_1C':$name;
249 $type = $info[
'TYPE'] ??
'';
251 if($type === self::TYPE_DATE || $type === self::TYPE_DATETIME)
259 $time = strtotime($value);
263 if($date instanceof
Date)
269 $result->addError(
new Error(
'internalize data field error', 0));
272 elseif($type === self::TYPE_FILE)
276 $result->addData([$value]);
285 foreach ($fields as $name=>$value)
287 $info = isset($fieldsInfo[$name]) ? $fieldsInfo[$name]:
null;
296 $value = current($r->getData());
303 $result[$name] = $value;
312 $fieldsInfo = empty($fieldsInfo)? $this->
getFields():$fieldsInfo;
314 if(is_array($fields) && count($fields)>0)
318 foreach ($fields as $rawName=>$value)
320 $field = \CSqlUtil::GetFilterOperation($rawName);
322 $info = isset($listFieldsInfo[$field[
'FIELD']]) ? $listFieldsInfo[$field[
'FIELD']]:
null;
331 $value = current($r->getData());
338 $operation = mb_substr($rawName, 0, mb_strlen($rawName) - mb_strlen($field[
'FIELD']));
339 if(isset($info[
'FORBIDDEN_FILTERS'])
340 && is_array($info[
'FORBIDDEN_FILTERS'])
341 && in_array($operation, $info[
'FORBIDDEN_FILTERS'],
true))
346 $result[$rawName]=$value;
356 $fieldsInfo = empty($fieldsInfo)? $this->
getFields():$fieldsInfo;
360 if(empty($fields) || in_array(
'*', $fields,
true))
362 $result = array_keys($listFieldsInfo);
366 foreach ($fields as $name)
368 $info = isset($listFieldsInfo[$name]) ? $listFieldsInfo[$name]:
null;
385 $fieldsInfo = empty($fieldsInfo)? $this->
getFields():$fieldsInfo;
392 foreach ($fields as $field=>$order)
394 $info = isset($listFieldsInfo[$field]) ? $listFieldsInfo[$field]:
null;
400 $result[$field]=$order;
409 $filter = isset($arguments[
'filter']) ? $this->
rewriteFilterFields($arguments[
'filter']):[];
410 $select = isset($arguments[
'select']) ? $this->
rewriteSelectFields($arguments[
'select']):[];
411 $order = isset($arguments[
'order']) ? $this->
rewriteOrderFields($arguments[
'order']):[];
425 foreach ($fields as $name)
427 $fieldsIsAlias = isset($rewriteFields[$name]);
431 if(isset($rewriteFields[$name][
'REFERENCE_FIELD']))
433 $result[$name] = $rewriteFields[$name][
'REFERENCE_FIELD'];
451 foreach ($fields as $rawName=>$value)
453 $field = \CSqlUtil::GetFilterOperation($rawName);
455 $fieldsIsAlias = isset($rewriteFields[$field[
'FIELD']]);
459 if(isset($rewriteFields[$field[
'FIELD']][
'REFERENCE_FIELD']))
461 $originalName = $rewriteFields[$field[
'FIELD']][
'REFERENCE_FIELD'];
462 $operation = mb_substr($rawName, 0, mb_strlen($rawName) - mb_strlen($field[
'FIELD']));
463 $result[$operation.$originalName] = $value;
468 $result[$rawName] = $value;
480 foreach ($fields as $name=>$value)
482 $fieldsIsAlias = isset($rewriteFields[$name]);
486 if(isset($rewriteFields[$name][
'REFERENCE_FIELD']))
488 $result[$rewriteFields[$name][
'REFERENCE_FIELD']] = $value;
493 $result[$name] = $value;
513 $fieldsInfo = empty($fieldsInfo) ? $this->
getFields():$fieldsInfo;
517 if(is_array($list) && count($list)>0)
519 foreach ($list as $k=>$item)
535 if(is_array($fields) && count($fields)>0)
537 foreach($fields as $name => $value)
539 $info = isset($fieldsInfo[$name]) ? $fieldsInfo[$name] :
null;
553 $type = isset($info[
'TYPE']) ? $info[
'TYPE']:
'';
554 if($type === self::TYPE_FILE)
559 $result[$name] = $value;
568 if(is_array($list) && count($list)>0)
570 foreach($list as $k=>$fields)
606 return Converter::toJson()
617 if(!$required->isSuccess())
618 $r->addError(
new Error(
'Required fields: '.implode(
', ', $required->getErrorMessages())));
628 if(!$required->isSuccess())
629 $r->addError(
new Error(
'Required fields: '.implode(
', ', $required->getErrorMessages())));
639 if(!$required->isSuccess())
640 $r->addError(
new Error(
'Required fields: '.implode(
' ', $required->getErrorMessages())));
680 $addRequiredFields = is_set($params,
'+required') ? $params[
'+required']:[];
681 $delRequiredFields = is_set($params,
'-required') ? $params[
'-required']:[];
685 if(in_array($name, $delRequiredFields))
689 elseif($info[
'IS_REQUIRED'] ==
'Y' || in_array($name, $addRequiredFields))
691 if(!is_set($fields, $name))
static createFromTimestamp($timestamp)
checkRequiredFieldsAdd($fields)
externalizeListFields($list)
externalizeFields($fields)
rewriteFieldsList($arguments)
internalizeFieldValue($value, $info)
checkFieldsUpdate($fields)
internalizeFieldsTryUpdate($fields)
internalizeFieldsTryModify($fields)
internalizeSelectFields($fields, array $fieldsInfo)
internalizeArguments($name, $arguments)
convertKeysToCamelCase($fields)
getListFieldInfo(array $fieldsInfo, $params=[])
internalizeFilterFields($fields, array $fieldsInfo)
rewriteSelectFields($fields)
checkFieldsModify($fields)
externalizeFieldsModify($fields)
externalizeFieldsTryModify($fields)
convertKeysToSnakeCaseOrder($fields)
convertKeysToSnakeCaseArguments($name, $arguments)
prepareFieldInfos($fields)
checkArguments($name, $arguments)
convertKeysToSnakeCase($data)
rewriteOrderFields($fields)
internalizeFieldsTryAdd($fields)
internalizeOrderFields($fields, array $fieldsInfo)
internalizeFieldsUpdate($fields)
convertKeysToSnakeCaseSelect($fields)
checkRequiredFieldsUpdate($fields)
internalizeFieldsList($arguments)
externalizeResult($name, $fields)
checkRequiredFieldsModify($fields)
internalizeFields($fields, array $fieldsInfo)
internalizeListFields($list, $fieldsInfo=[])
convertKeysToSnakeCaseFields($fields)
internalizeFieldsAdd($fields)
convertKeysToSnakeCaseFilter($fields)
rewriteFilterFields($fields)
checkRequiredFields($fields, array $fieldsInfo, $params=[])
internalizeFieldsModify($fields)