AbstractEntity::mapObjectToArray bug when multiple collections are used
There is an error in the service of Collection types in the mapObjectToArray method of AbstractEntity. When in the one property model it is served correctly. But if 2 or more properties, than the data of the previous property fall into the collection of the next property. Below is the code:
public function mapObjectToArray()
{
$reflectionClassObject = new \ReflectionObject($this);
foreach ($reflectionClassObject->getProperties() as $property) {
...
if ($reflectionClassObject->hasMethod($method)) {
...
} elseif ($propValue instanceof PersistentCollection) {
foreach ($propValue->toArray() as $item) {
$tmp[] = $item->mapObjectToArray();
}
$ret[$propName] = $tmp?? [];
} elseif ($propValue !== $this) {
...
}
}
return $ret ?? [];
}
Must be added before " foreach ($propValue->toArray() as $item) { " clearing temporary variable $tmp = [];
That is,
} elseif ($propValue instanceof PersistentCollection) {
$tmp = [];
foreach ($propValue->toArray() as $item) {
$tmp[] = $item->mapObjectToArray();
}
$ret[$propName] = $tmp?? [];
} elseif ($propValue !== $this) {