/**
  * Map using the @MapTo() annotations found in the object
  * @param object $modelOrClass A class or object to map from
  * @param object $entityOrClass A class or object to map to
  */
 public function mapFromModel($modelOrClass, $entityOrClass)
 {
     $class = new \ReflectionClass($modelOrClass);
     $annotationName = 'Rezonant\\MapperBundle\\Annotations\\MapTo';
     $transformationAnnotationName = 'Rezonant\\MapperBundle\\Annotations\\Transformation';
     $excludeAnnotationName = 'Rezonant\\MapperBundle\\Annotations\\Exclude';
     $map = new MapBuilder();
     $destinationClass = new \ReflectionClass($entityOrClass);
     foreach ($class->getProperties() as $property) {
         $annotation = $this->annotationReader->getPropertyAnnotation($property, $annotationName);
         $transformationAnnotation = $this->annotationReader->getPropertyAnnotation($property, $transformationAnnotationName);
         $excludeAnnotation = $this->annotationReader->getPropertyAnnotation($property, $excludeAnnotationName);
         // Resolve the type of this property for submapping later.
         $subSourceType = $this->reflector->getTypeFromProperty($property);
         $subDestType = null;
         $fieldValue = null;
         $submap = null;
         $destinationField = null;
         $exclude = false;
         // Use the annoted destination field, or assume that the mapping
         // is 1-to-1.
         if ($annotation) {
             $destinationField = $annotation->value;
         } else {
             if ($destinationClass->hasProperty($property->name)) {
                 $destinationField = $property->name;
             }
         }
         //Get transformation if there is one
         $transformation = $this->getTransformationFromAnnotation($transformationAnnotation);
         if ($excludeAnnotation) {
             $exclude = true;
         }
         // Resolve the destination field's type for generating a submap.
         if ($destinationField) {
             $destReference = new Reference($destinationField, $destinationClass);
             $subDestTypes = $destReference->getTypes();
             $subDestType = $subDestTypes[count($subDestTypes) - 1];
             if ($subSourceType && $subDestType) {
                 $submap = $this->mapFromModel($subSourceType, $subDestType);
             }
             $map->field(new Reference($property->name, $class), $destReference, $submap, $transformation, $exclude);
         }
     }
     return $map->build();
 }