22 foreach($fields as $name => $info)
24 $attributs = isset($info[
'ATTRIBUTES']) ? $info[
'ATTRIBUTES'] : [];
39 $intersectRequired = array_intersect([
46 'TYPE' => $info[
'TYPE'],
47 'IS_REQUIRED' => count($intersectRequired) > 0,
57 $filter = isset($params[
'filter'])?$params[
'filter']:[];
58 $ignoredAttributes = isset($filter[
'ignoredAttributes'])?$filter[
'ignoredAttributes']:[];
59 $ignoredFields = isset($filter[
'ignoredFields'])?$filter[
'ignoredFields']:[];
60 $skipFields = isset($filter[
'skipFields'])?$filter[
'skipFields']:[];
62 foreach ($fieldsInfo as $name=>$info)
64 if(in_array($name, $ignoredFields))
68 elseif(in_array($name, $skipFields) ==
false)
70 if(isset($info[
'ATTRIBUTES']))
72 $skipAttr = array_intersect($ignoredAttributes, $info[
'ATTRIBUTES']);
94 $converter =
new Converter(Converter::VALUES | Converter::TO_SNAKE | Converter::TO_SNAKE_DIGIT | Converter::TO_UPPER);
95 return $converter->process($fields);
107 $converter =
new Converter(Converter::VALUES | Converter::TO_UPPER);
108 $converterForKey =
new Converter(Converter::KEYS | Converter::TO_SNAKE | Converter::TO_SNAKE_DIGIT | Converter::TO_UPPER);
110 foreach ($converter->process($fields) as $key=>$value)
112 $result[$converterForKey->process($key)] = $value;
125 $converter =
new Converter(Converter::KEYS | Converter::RECURSIVE | Converter::TO_SNAKE | Converter::TO_SNAKE_DIGIT | Converter::TO_UPPER);
126 return $converter->process($data);
138 $fieldsInfo = empty($fieldsInfo) ? $this->
getFields():$fieldsInfo;
155 $fieldsInfo = empty($fieldsInfo) ? $this->
getFields():$fieldsInfo;
168 $fieldsInfo = empty($fieldsInfo) ? $this->
getFields():$fieldsInfo;
183 foreach ($fields as $name=>$value)
185 $info = isset($fieldsInfo[$name]) ? $fieldsInfo[$name]:
null;
193 if($r->isSuccess() ===
false)
207 $type = isset($info[
'TYPE']) ? $info[
'TYPE']:
'';
211 $value = floatval($value);
215 $value = (int)$value;
221 if($date->isSuccess())
223 $value = $date->getData()[0];
227 $r->addErrors($date->getErrors());
234 if($date->isSuccess())
236 $value = $date->getData()[0];
240 $r->addErrors($date->getErrors());
252 $value = $r->getData()[0];
258 $r->setData([$value]);
270 if($date instanceof
Date)
276 $r->addError(
new Error(
'Wrong type date'));
281 $r->setData([$value]);
299 $r->addError(
new Error(
'Wrong type datetime'));
304 $r->setData([$value]);
318 $time = strtotime($value);
319 $date = ($time) ? \
Bitrix\Main\
Type\Date::createFromTimestamp($time):
'';
332 $time = strtotime($value);
342 $remove = isset($value[
'REMOVE']) && is_string($value[
'REMOVE']) && mb_strtoupper($value[
'REMOVE']) ===
'Y';
343 $data = isset($value[
'FILE_DATA']) ? $value[
'FILE_DATA'] : [];
347 $content = isset($data[
'CONTENT']) ? $data[
'CONTENT']:
'';
348 $name = isset($data[
'NAME']) ? $data[
'NAME']:
'';
350 if(is_string($content) && $content !==
'')
353 $fileInfo = \CRestUtil::saveFile($content, $name);
354 if(is_array($fileInfo))
362 $result = [
'del'=>
'Y'];
372 $r->setData([$value]);
379 $count = count($data);
397 return [
'CONTENT'=>$content,
'NAME'=>$name];
404 $fieldsInfo = empty($fieldsInfo)? $this->
getFields():$fieldsInfo;
406 if (is_array($fields) && !empty($fields))
410 foreach ($fields as $rawName=>$value)
412 $field = \CSqlUtil::GetFilterOperation($rawName);
414 $info = isset($listFieldsInfo[$field[
'FIELD']]) ? $listFieldsInfo[$field[
'FIELD']]:
null;
422 if ($r->isSuccess() ===
false)
427 $operation = mb_substr($rawName, 0, mb_strlen($rawName) - mb_strlen($field[
'FIELD']));
428 if (isset($info[
'FORBIDDEN_FILTERS'])
429 && is_array($info[
'FORBIDDEN_FILTERS'])
430 && in_array($operation, $info[
'FORBIDDEN_FILTERS'],
true))
435 $rawName = $operation.$this->canonicalizeField($field[
'FIELD'], $info);
437 $result[$rawName] = $r->getData()[0];
448 $fieldsInfo = empty($fieldsInfo)? $this->
getFields():$fieldsInfo;
452 if (empty($fields) || in_array(
'*', $fields,
true))
454 $fields = array_keys($listFieldsInfo);
457 foreach ($fields as $name)
459 $info = isset($listFieldsInfo[$name]) ? $listFieldsInfo[$name]:
null;
475 $fieldsInfo = empty($fieldsInfo)? $this->
getFields():$fieldsInfo;
477 if (is_array($fields) && count($fields)>0)
481 foreach ($fields as $field => $order)
483 $info = isset($listFieldsInfo[$field]) ? $listFieldsInfo[$field]:
null;
500 $fieldsInfo = empty($fieldsInfo) ? $this->
getFields():$fieldsInfo;
504 if(is_array($list) && count($list)>0)
506 foreach ($list as $k=>$item)
520 $type = isset($fieldsInfo[$name][
'TYPE']) ? $fieldsInfo[$name][
'TYPE']:
'';
530 $value = floatval($value);
534 $value = (int)$value;
540 if($date->isSuccess())
542 $value = $date->getData()[0];
546 $r->addErrors($date->getErrors());
553 if($date->isSuccess())
555 $value = $date->getData()[0];
559 $r->addErrors($date->getErrors());
571 $value = $r->getData()[0];
578 $r->setData([$value]);
588 if(is_array($fields) && count($fields)>0)
590 foreach($fields as $name => $value)
594 $info = isset($fieldsInfo[$name]) ? $fieldsInfo[$name] :
null;
602 if ($r->isSuccess() ===
false)
607 $result[$name] = $r->getData()[0];
622 $time = strtotime($value);
623 $value = ($time) ? \
Bitrix\Main\
Type\Date::createFromTimestamp($time):
'';
627 $r->setData([$value]);
637 $time = strtotime($value);
642 $r->setData([$value]);
670 $r->setData([$value]);
679 $fieldsInfo = empty($fieldsInfo) ? $this->
getFields():$fieldsInfo;
683 if(is_array($list) && count($list)>0)
685 foreach($list as $k=>$fields)
704 $fieldsInfo = empty($fieldsInfo) ? $this->
getFields():$fieldsInfo;
722 if(!$required->isSuccess())
723 $r->addError(
new Error(
'Required fields: '.implode(
', ', $required->getErrorMessages())));
733 if(!$required->isSuccess())
734 $r->addError(
new Error(
'Required fields: '.implode(
', ', $required->getErrorMessages())));
769 $addRequiredFields = isset($params[
'+required']) ? $params[
'+required']:[];
770 $delRequiredFields = isset($params[
'-required']) ? $params[
'-required']:[];
774 if(in_array($name, $delRequiredFields))
778 elseif($info[
'IS_REQUIRED'] ==
'Y' || in_array($name, $addRequiredFields))
780 if(!isset($fields[$name]))
792 $canonical = $info[
'CANONICAL_NAME'] ??
null;
809 $item = array_filter($fieldsInfo,
function($info) use ($name){
810 $canonical = $info[
'CANONICAL_NAME'] ??
null;
816 return $canonical === $name;
819 if (is_array($item) && !empty($item))
821 $alias = array_keys($item)[0];
static createFromTimestamp($timestamp)
static convertKeysToCamelCase($fields)
checkRequiredFieldsAdd($fields)
externalizeExtendedTypeValue($name, $value, $fields, $fieldsInfo)
aliasesField($name, $fieldsInfo)
checkFieldsUpdate($fields)
parserFileValue(array $data)
canonicalizeField($name, $info)
internalizeFieldsList($arguments, $fieldsInfo=[])
internalizeSelectFields($fields, array $fieldsInfo)
externalizeFields($fields, $fieldsInfo)
internalizeArguments($name, $arguments)
internalizeFieldsAdd($fields, $fieldsInfo=[])
getListFieldInfo(array $fieldsInfo, $params=[])
internalizeFilterFields($fields, array $fieldsInfo)
externalizeValue($name, $value, $fields, $fieldsInfo)
convertKeysToSnakeCaseOrder($fields)
internalizeDateTimeValue($value)
convertKeysToSnakeCaseArguments($name, $arguments)
externalizeFieldsGet($fields, $fieldsInfo=[])
prepareFieldInfos($fields)
checkArguments($name, $arguments)
convertKeysToSnakeCase($data)
internalizeFieldsUpdate($fields, $fieldsInfo=[])
externalizeFileValue($name, $value, $fields)
internalizeOrderFields($fields, array $fieldsInfo)
convertKeysToSnakeCaseSelect($fields)
externalizeDateValue($value)
checkRequiredFieldsUpdate($fields)
externalizeListFields($list, $fieldsInfo=[])
externalizeResult($name, $fields)
prepareFieldAttributs($info, $attributs)
internalizeFields($fields, array $fieldsInfo)
internalizeListFields($list, $fieldsInfo=[])
convertKeysToSnakeCaseFields($fields)
internalizeValue($value, $info)
internalizeFileValue($value)
convertKeysToSnakeCaseFilter($fields)
internalizeDateValue($value)
externalizeDateTimeValue($value)
internalizeDateTime($value)
checkRequiredFields($fields, array $fieldsInfo, $params=[])
checkFieldsList($arguments)
externalizeEmptyValue($name, $value, $fields, $fieldsInfo)
internalizeExtendedTypeValue($value, $info)