/**
  * Add mapping data to a translation entity
  *
  * @param ClassMetadata $metadata
  */
 private function mapTranslation(ClassMetadata $metadata)
 {
     // In the case A -> B -> TranslationInterface, B might not have mapping defined as it
     // is probably defined in A, so in that case, we just return;
     if (!isset($this->mappings[$metadata->name])) {
         return;
     }
     $config = $this->mappings[$metadata->name];
     $mapping = $config['translation']['mapping'];
     $metadata->isEmbeddedDocument = true;
     $metadata->isMappedSuperclass = false;
     $metadata->setIdentifier(null);
     // Map locale field.
     if (!$metadata->hasField($mapping['translation']['locale'])) {
         $metadata->mapField(array('fieldName' => $mapping['translation']['locale'], 'type' => 'string'));
     }
     // Map unique index.
     $keys = array($mapping['translation']['translatable'] => 1, $mapping['translation']['locale'] => 1);
     if (!$this->hasUniqueIndex($metadata, $keys)) {
         $metadata->addIndex($keys, array('unique' => true));
     }
 }