#925 REST/JSON: Added an option to output all the fields of the object found (not only the fields of the queried class)

SVN:trunk[3163]
This commit is contained in:
Romain Quetiez
2014-05-20 08:15:53 +00:00
parent b0a84f96f1
commit 3e79dad435
2 changed files with 40 additions and 11 deletions

View File

@@ -715,7 +715,7 @@ class RestUtils
* @param string $sClass Name of the class
* @param StdClass $oData Structured input data.
* @param string $sParamName Name of the parameter to fetch from the input data
* @return void
* @return An array of class => list of attributes (see RestResultWithObjects::AddObject that uses it)
* @throws Exception
* @api
*/
@@ -727,7 +727,17 @@ class RestUtils
{
foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
{
$aShowFields[] = $sAttCode;
$aShowFields[$sClass][] = $sAttCode;
}
}
elseif ($sFields == '*+')
{
foreach (MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL) as $sRefClass)
{
foreach (MetaModel::ListAttributeDefs($sRefClass) as $sAttCode => $oAttDef)
{
$aShowFields[$sRefClass][] = $sAttCode;
}
}
}
else
@@ -739,7 +749,7 @@ class RestUtils
{
throw new Exception("$sParamName: invalid attribute code '$sAttCode'");
}
$aShowFields[] = $sAttCode;
$aShowFields[$sClass][] = $sAttCode;
}
}
return $aShowFields;