Skip to content

Commit

Permalink
oh lol
Browse files Browse the repository at this point in the history
  • Loading branch information
Acrack committed Nov 7, 2014
1 parent 2082e4c commit ca1baaf
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Entity/TranslationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,22 @@ public function translate($entity, $field, $locale, $fieldData)
$listener->setTranslationInDefaultLocale(spl_object_hash($entity), $field, $trans);
} else {
$translationClassRepository = $this->em->getRepository($entityTranslationClass);
$meta = $em->getClassMetadata(get_class($entity));
$identifier = $meta->getSingleIdentifierFieldName();
$meta = $em->getClassMetadata(get_class($entity));
$identifier = $meta->getSingleIdentifierFieldName();
$translation = null;

if ($this->propertyAccessor->getValue($entity->getId(), $identifier)) {
if ($entity && $this->propertyAccessor->getValue($entity, $identifier)) {
$translation = $translationClassRepository->findOneBy(array(
'locale' => $locale,
'field' => $field,
'object' => $entity,
));
} else {
$translation = null;
}

if ($translation) {
$translation->setContent($fieldData);
} else {
if ($fieldData !== null) {
$entity->addTranslation(new $entityTranslationClass($locale, $field, $fieldData));
}
} elseif ($fieldData !== null) {
$entity->addTranslation(new $entityTranslationClass($locale, $field, $fieldData));
}
}
}
Expand Down

0 comments on commit ca1baaf

Please sign in to comment.