/**
  * Create a schema array for *-to-many associations
  *
  * @param array $sourceAssociation
  * @return ForestField|null
  * @throws \Doctrine\ORM\Mapping\MappingException
  */
 protected function getFieldForToManyAssociation($sourceAssociation)
 {
     $targetClassMetadata = $this->getClassMetadata($sourceAssociation['targetEntity']);
     $type = $this->getTypeForAssociation($sourceAssociation);
     $fieldName = $sourceAssociation['fieldName'];
     $inverseOf = $sourceAssociation['inversedBy'];
     $foreignTableName = $targetClassMetadata->getTableName();
     $foreignIdentifier = $targetClassMetadata->getIdentifier();
     //if(count($foreignIdentifier) > 1) die(__METHOD__.'::'.__LINE__.': '.$foreignTableName.' has more than one identifier : '.json_encode($foreignIdentifier));
     $foreignIdentifier = reset($foreignIdentifier);
     $reference = $foreignTableName . '.' . $foreignIdentifier;
     $field = new ForestField($fieldName, $type, $reference, $inverseOf);
     if (array_key_exists('joinTable', $sourceAssociation)) {
         if (!empty($sourceAssociation['joinTable'])) {
             $pivot = new Pivot($sourceAssociation['joinTable']['joinColumns'][0]['name'], $sourceAssociation['joinTable']['inverseJoinColumns'][0]['name'], $sourceAssociation['joinTable']['name']);
             $field->setPivot($pivot);
         }
     }
     return $field;
 }