private function addMappingFromReference(ClassMetadata $class, $fieldName, $reference, $type)
{
/** @var $class \Doctrine\ODM\PHPCR\Mapping\ClassMetadata */
$mapping = array_merge(array('fieldName' => $fieldName), $reference);
$mapping['cascade'] = isset($reference['cascade']) ? $this->getCascadeMode($reference['cascade']) : 0;
$mapping['name'] = isset($reference['name']) ? $reference['name'] : null;
if (!isset($mapping['targetDocument'])) {
$mapping['targetDocument'] = null;
}
if ($type === 'many') {
$class->mapManyToMany($mapping);
} elseif ($type === 'one') {
$class->mapManyToOne($mapping);
}
}