-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
In JSONDataFormatter
line 119 and 151 a baked-in set of three fields are returned for each object in a has_xxx relation which doesn't allow for much in the way of customisation, viz:
$serobj->$relName = ArrayData::array_to_object(array(
"className" => $relClass,
"href" => "$href.json",
"id" => $obj->$fieldName
));
We should allow developers to specify additional fields to return here, declared in YML config viz:
$serobj->$relName = ArrayData::array_to_object(array_replace([
"className" => $relClass,
"href" => "$href.json",
"id" => $obj->$fieldName
], $obj->config()->get('api_fields'));
Note the use of array_replace()
so that userland config can also override the defaults, not simply append to them (Not completely sure the latter is a good idea...)