public function getDocumentActualData($document)
{
$class = $this->dm->getClassMetadata(get_class($document));
$actualData = array();
foreach ($class->reflFields as $name => $refProp) {
$mapping = $class->fieldMappings[$name];
// skip not saved fields
if (isset($mapping['notSaved']) && $mapping['notSaved'] === true) {
continue;
}
$value = $refProp->getValue($document);
if (isset($mapping['file']) && !$value instanceof GridFSFile) {
$value = new GridFSFile($value);
$class->reflFields[$name]->setValue($document, $value);
$actualData[$name] = $value;
} elseif (isset($mapping['association']) && $mapping['type'] === 'many' && $value !== null && !$value instanceof PersistentCollectionInterface) {
// If $actualData[$name] is not a Collection then use an ArrayCollection.
if (!$value instanceof Collection) {
$value = new ArrayCollection($value);
}
// Inject PersistentCollection
$coll = $this->dm->getConfiguration()->getPersistentCollectionFactory()->create($this->dm, $mapping, $value);
$coll->setOwner($document, $mapping);
$coll->setDirty(!$value->isEmpty());
$class->reflFields[$name]->setValue($document, $coll);
$actualData[$name] = $coll;
} else {
$actualData[$name] = $value;
}
}
return $actualData;
}