I have a question regarding the ElementAPI:
I am sucessfully using the ElementAPI to fetch assets related to an entry. Now I have a matrix field where a user can add multiple galleries (multiple block of selected assets) and i want to retrieve the images. But I can't figure out how to use it for nested matrix blocks...
This is how I fetch the data with ElementAPI from non-matrix assets fields (elementapi.php
config)
'endpoints' => [
'api/v1/installation-views/<sourceEntryId:\d+>/<fieldHandle:[A-Za-z]+>' => function($sourceEntryId, $fieldHandle) {
return [
'elementType' => 'Asset',
'criteria' => [
'relatedTo' => [
'sourceElement' => $sourceEntryId,
'field' => $fieldHandle
],
'kind' => 'image'
],
'transformer' => function(AssetFileModel $asset) {
return [
'id' => $asset->id,
'title' => $asset->title,
...
];
},
];
}
]
How would I do that for asset fields nested inside a matrix block? I guess I can't use the nested field handle as handle?