/**
  * @param array $root
  * @param \Doctrine\ORM\ODMAdapter\Mapping\ClassMetadata|ClassMetadata $class
  * @param $className
  * @param $targetReferencedObjectField
  */
 public function extractCommonFields(array $root, ClassMetadata $class, $className, $targetReferencedObjectField)
 {
     foreach ($root as $field) {
         $mapping = array('type' => 'common-field');
         foreach ($field as $key => $value) {
             if (is_string($value)) {
                 $value = 'null' !== $value ? $value : null;
                 $mapping[$key] = (string) $value;
             }
         }
         $mapping['target-field'] = $targetReferencedObjectField;
         $class->mapCommonField($mapping);
     }
 }
 protected function extractCommonField($annotations, ClassMetadata $class, $className, $targetReferencedObjectField)
 {
     if (!is_array($annotations)) {
         return;
     }
     foreach ($annotations as $annotation) {
         $mapping = array('type' => 'common-field');
         if (isset($annotation->referencedBy)) {
             $mapping['referenced-by'] = $annotation->referencedBy;
         }
         if (isset($annotation->inversedBy)) {
             $mapping['inversed-by'] = $annotation->inversedBy;
         }
         if (isset($annotation->syncType)) {
             $mapping['sync-type'] = $annotation->syncType;
         }
         $mapping['target-field'] = $targetReferencedObjectField;
         $class->mapCommonField($mapping);
     }
 }
 /**
  * @param SimpleXMLElement $xmlRoot
  * @param \Doctrine\ORM\ODMAdapter\Mapping\ClassMetadata|ClassMetadata $class
  * @param $className
  * @param $targetReferencedObjectField
  */
 protected function extractCommonFields(SimpleXMLElement $xmlRoot, ClassMetadata $class, $className, $targetReferencedObjectField)
 {
     if (!isset($xmlRoot->{'common-field'})) {
         return;
     }
     foreach ($xmlRoot->{'common-field'} as $field) {
         $mapping = array('type' => 'common-field');
         $attributes = $field->attributes();
         foreach ($attributes as $key => $value) {
             $mapping[$key] = (string) $value;
         }
         $mapping['target-field'] = $targetReferencedObjectField;
         $class->mapCommonField($mapping);
     }
 }