/**
  * Fills a documents versioned fields with data
  *
  * @param object $document
  * @param array $data
  */
 protected function fillDocument($document, array $data)
 {
     $wrapped = new MongoDocumentWrapper($document, $this->dm);
     $objectMeta = $wrapped->getMetadata();
     $config = $this->getLoggableListener()->getConfiguration($this->dm, $objectMeta->name);
     $fields = $config['versioned'];
     foreach ($data as $field => $value) {
         if (!in_array($field, $fields)) {
             continue;
         }
         $mapping = $objectMeta->getFieldMapping($field);
         // Fill the embedded document
         if ($wrapped->isEmbeddedCollectionAssociation($field)) {
             if (!empty($value)) {
                 $items = [];
                 foreach ($value as $item) {
                     $items[] = $this->fillEmbeddedDocument($item, $mapping);
                 }
                 $value = new ArrayCollection($items);
             }
         } elseif ($wrapped->isEmbeddedAssociation($field)) {
             $value = $this->fillEmbeddedDocument($value, $mapping);
         } elseif ($objectMeta->isSingleValuedAssociation($field)) {
             $value = $value ? $this->dm->getReference($mapping['targetDocument'], $value) : null;
         }
         $wrapped->setPropertyValue($field, $value);
         unset($fields[$field]);
     }
     /*
     if (count($fields)) {
         throw new \Gedmo\Exception\UnexpectedValueException('Cound not fully revert the document to version: '.$version);
     }
     */
 }