- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/restservice.php
- Класс: CTaskRestService
- Вызов: CTaskRestService::_parseReturnValue
static function _parseReturnValue($className, $methodName, $returnValue, $params)
{
if(is_callable($className.'::postProcessRestRequest'))
{
$returnValue = $className::postProcessRestRequest($methodName, $returnValue, $params);
}
CTaskAssert::assert(isset(self::$arMethodsMetaInfo[$className][$methodName]));
$parsedValue = null;
$arDateFields = array();
if (isset(self::$arManifests[$className]['REST: date fields']))
$arDateFields = self::$arManifests[$className]['REST: date fields'];
$arMethodMetaInfo = self::$arMethodsMetaInfo[$className][$methodName];
// Function returns an array of file ids?
if (
isset($arMethodMetaInfo['fileIdsReturnValue'])
&& ($arMethodMetaInfo['fileIdsReturnValue'] === true)
&& is_array($returnValue)
)
{
$parsedValue = array();
foreach ($returnValue as &$fileId)
$parsedValue[] = '/bitrix/components/bitrix/tasks.task.detail/show_file.php?fid=' . (int) $fileId;
unset($fileId);
}
else if (is_array($returnValue) && isset($arMethodMetaInfo['allowedKeysInReturnValue']))
{
// add legal aggregated columns in result array
if(is_array($arMethodMetaInfo['allowedAggregations']))
{
if(is_array($arMethodMetaInfo['allowedValuesInAggregation']))
$fields = $arMethodMetaInfo['allowedValuesInAggregation'];
else
$fields = $arMethodMetaInfo['allowedKeysInReturnValue'];
if(is_array($fields))
{
$aggrCombos = static::getAllowedAggregateCombos($arMethodMetaInfo['allowedAggregations'], $fields);
$arMethodMetaInfo['allowedKeysInReturnValue'] = array_merge($arMethodMetaInfo['allowedKeysInReturnValue'], $aggrCombos);
}
}
if (
isset($arMethodMetaInfo['collectionInReturnValue'])
&& ($arMethodMetaInfo['collectionInReturnValue'] === true)
)
{
$parsedValue = array();
foreach ($returnValue as $valueToBeFiltered)
{
$parsedValue[] = self::_filterArrayByAllowedKeys( // Additionally converts datetime fields
$valueToBeFiltered,
$arMethodMetaInfo['allowedKeysInReturnValue'],
$arDateFields
);
}
}
else
{
$parsedValue = self::_filterArrayByAllowedKeys( // Additionally converts datetime fields
$returnValue,
$arMethodMetaInfo['allowedKeysInReturnValue'],
$arDateFields
);
}
}
else
{
$parsedValue = $returnValue;
}
return ($parsedValue);
}