Manual:ApiResult.php/en

The ApiResult class represents the result of the API operations.

It simply wraps a nested array structure, adding some functions to simplify array's modifications. As various modules execute, they add different pieces of information to this result, structuring it as it will be given to the client.

Each subarray may either be a dictionary - key-value pairs with unique keys, or lists, where the items are added using  notation.

There are two special key values that change how XML output is generated:


 * '_element' - This key sets the tag name for the rest of the elements in the current array. It is only inserted if the formatter returned true for getNeedsRawData
 * '*' - This key has special meaning only to the XML formatter, and is output as is for all others. In XML it becomes the content of the current element.

addValue
Add value to the output data at the given path.

Path can be an indexed array, each element specifying the branch at which to add the new value. Setting $path to array('a','b','c') is equivalent to data['a']['b']['c'] = $value. If $path is null, the value will be inserted at the data root. If $name is empty, the $value is added as a next list element data[] = $value.