I am using Propel 2. I am hydrating objects through the relations, like so:
$return = OrderQuery::create()
->joinWith('Customer')
->joinWith('Status')
->find()
->toArray(TableMap::TYPE_PHPNAME, true, [], true);
The resulting Array would look something like this:
{
"Id": 1,
"CustomerId": 1,
"StatusId": 1,
"Initiated": "2016-01-01T01:01:01+00:00",
"Customer": {
"Id": 1,
"Forname": "Test",
"Surname": "Smith",
"Orders": [
"*RECURSION*"
]
}
"Status": {
"Id": 1,
"Title": "title 1",
"Priority": 1,
"Orders": [
"*RECURSION*"
]
},
}
I want to remove the fields where the value is *RECURSION*
. I tried using the $alreadyDumpedObjects
(3rd) parameter to toArray()
but that didn't seem to help. I could also do some form of array walking with unset()
calls, but I'm hoping there's a better way, maybe with a formatter or something?
For bonus points, I'd quite like to remove the columns which define the foreign key relationship. For instance, CustomerId
would go, but Customer
would remain.