getDocumentActualData() public method

Get a documents actual data, flattening all the objects to arrays.
public getDocumentActualData ( object $document ) : array
$document object
return array
 /**
  * @param object $document
  *
  * @return array
  * @throws MongoDBException
  */
 private function getShardKeyQuery($document)
 {
     if (!$this->class->isSharded()) {
         return array();
     }
     $shardKey = $this->class->getShardKey();
     $keys = array_keys($shardKey['keys']);
     $data = $this->uow->getDocumentActualData($document);
     $shardKeyQueryPart = array();
     foreach ($keys as $key) {
         $mapping = $this->class->getFieldMappingByDbFieldName($key);
         $this->guardMissingShardKey($document, $key, $data);
         $value = Type::getType($mapping['type'])->convertToDatabaseValue($data[$mapping['fieldName']]);
         $shardKeyQueryPart[$key] = $value;
     }
     return $shardKeyQueryPart;
 }
 /**
  * @param $document
  * @return array
  * @throws MongoDBException
  */
 public function getShardKeyQuery($document)
 {
     $shardKeysQueryPart = array();
     $dcs = $this->uow->getDocumentChangeSet($document);
     $data = $this->uow->getDocumentActualData($document);
     $md = $this->dm->getMetadataFactory()->getMetadataFor(get_class($document));
     $keys = $md->shardKeys;
     $fieldMappings = $this->dm->getClassMetadata(get_class($document))->fieldMappings;
     foreach ($keys as $key) {
         if ($key !== 'id') {
             $queryKey = $fieldMappings[$key]['name'];
         } else {
             $queryKey = '_id';
         }
         //If the document is new, we can ignore shard key value, otherwise throw exception
         $isUpdate = $this->uow->isScheduledForUpdate($document);
         if ($isUpdate && isset($dcs[$key]) && $dcs[$key][0] !== null && $dcs[$key][0] != $dcs[$key][1] && (!isset($options['upsert']) || isset($options['upsert']) && $options['upsert'] === true)) {
             throw MongoDBException::shardKeyChange($key);
         }
         if (!isset($data[$key])) {
             throw MongoDBException::shardKeyMissing($key);
         }
         $new = $data[$key];
         $mapping = $fieldMappings[$key];
         // @Field, @String, @Date, etc.
         if (!isset($mapping['association'])) {
             if (isset($new) || $mapping['nullable'] === true) {
                 $shardKeysQueryPart[$queryKey] = is_null($new) ? null : Type::getType($mapping['type'])->convertToDatabaseValue($new);
             }
             // @ReferenceOne
         } elseif (isset($mapping['association']) && $mapping['association'] === ClassMetadata::REFERENCE_ONE && $mapping['isOwningSide']) {
             if (isset($new) || $mapping['nullable'] === true) {
                 $shardKeysQueryPart[$queryKey] = is_null($new) ? null : $this->pb->prepareReferencedDocumentValue($mapping, $new);
             }
             // @ReferenceMany
         } elseif (isset($mapping['association']) && $mapping['association'] === ClassMetadata::REFERENCE_MANY) {
             // Do nothing right now
         }
     }
     return $shardKeysQueryPart;
 }