/**
  * (Partially) hydrates the object and removes the affected (key, value) pairs from the return set.
  *
  * @param object $object
  * @param array  $data
  * @return array
  */
 public function hydrate($object, array $data)
 {
     if (!$object instanceof TaxonomyTermAwareInterface) {
         return $data;
     }
     $metadata = $this->objectManager->getClassMetadata(get_class($object));
     foreach ($data as $field => $value) {
         if ($metadata->hasAssociation($field) && is_object($value)) {
             $target = $metadata->getAssociationTargetClass($field);
             if ($target == 'Taxonomy\\Entity\\TaxonomyTerm') {
                 $this->taxonomyManager->associateWith($value, $object);
                 unset($data[$field]);
             }
         }
     }
     return $data;
 }