- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/delivery/rest/requestservice.php
- Класс: BitrixSaleDeliveryRestRequestService
- Вызов: RequestService::getRequestProperties
static function getRequestProperties(array $params, string $key): ?array
{
if (!isset($params[$key]))
{
return null;
}
if (!is_array($params[$key]))
{
throw new RestException(
sprintf('Unexpected properties (%s) format: array expected', $key),
self::ERROR_CODE_PROPERTIES_UNEXPECTED_FORMAT
);
}
$result = [];
foreach ($params[$key] as $propertyKey => $propertyValue)
{
$isExpectedFormat = (
is_array($propertyValue)
&& isset($propertyValue['NAME'])
&& is_string($propertyValue['NAME'])
&& !empty($propertyValue['NAME'])
&& isset($propertyValue['VALUE'])
&& is_string($propertyValue['VALUE'])
);
if (!$isExpectedFormat)
{
throw new RestException(
sprintf('Unexpected property value (%s.%s) format', $key, $propertyKey),
self::ERROR_CODE_PROPERTY_VALUE_UNEXPECTED_FORMAT
);
}
$resultItem = [
'NAME' => $propertyValue['NAME'],
'VALUE' => $propertyValue['VALUE'],
];
if (isset($propertyValue['TAGS']))
{
if (!is_array($propertyValue['TAGS']))
{
throw new RestException(
sprintf(
'Unexpected property value's tags format (%s.%s) format: array expected',
$key,
$propertyKey
),
self::ERROR_CODE_PROPERTY_VALUE_TAGS_UNEXPECTED_FORMAT
);
}
foreach ($propertyValue['TAGS'] as $tag)
{
if (!is_string($tag))
{
throw new RestException(
sprintf(
'Property value (%s.%s) tag must be of string type',
$key,
$propertyKey
),
self::ERROR_CODE_PROPERTY_VALUE_TAG_UNEXPECTED_FORMAT
);
}
}
$resultItem['TAGS'] = $propertyValue['TAGS'];
}
$result[] = $resultItem;
}
return $result;
}