Hi,
I have an array of entities (Doctrine objects) and I would like to transform it to JSON by leveraging Mautic loadApiMetada and serialization mechanism that is already provided by Mautic core so I can avoid manually composing the JSON.
Does anyone have any directions for me (has done this before) and knows what combination of services and method I need to use to get his?
Thanks.
Regards, M.
Update:
I am able to serialize the data using the follwoing line:
$this->webhookModel->serializeData($records);
The thing is that I would like to exclude some fields as they are not relevant for my situation. And I know this is possible to do because api response returns response without those fields.
I solved it by using:
use Mautic\ApiBundle\Serializer\Exclusion\FieldExclusionStrategy;
$this->webhookModel->serializeData($records, null, [
new FieldExclusionStrategy([
'Changes',
'PastChanges'
], 0)
]);
I simply excluded the fields I did not want in JSON.