Created
May 22, 2012 13:32
-
-
Save damienalexandre/2769074 to your computer and use it in GitHub Desktop.
How to use the translationClass option in the default Translatable repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Gedmo/Translatable/Entity/Repository/TranslationRepository.php b/lib/Gedmo/Translatable/Entity/Repository/TranslationRepository.php | |
index 50b106e..2451fd0 100644 | |
--- a/lib/Gedmo/Translatable/Entity/Repository/TranslationRepository.php | |
+++ b/lib/Gedmo/Translatable/Entity/Repository/TranslationRepository.php | |
@@ -64,9 +64,14 @@ class TranslationRepository extends EntityRepository | |
$entityClass = $wrapped->getMetadata()->name; | |
$translationMeta = $this->getClassMetadata(); // table inheritance support | |
+ | |
+ // Get the custom translationClass | |
+ $config = $this->getTranslationListener()->getConfiguration($this->_em, get_class($entity)); | |
+ $translationClass = isset($config['translationClass']) ? $config['translationClass'] : $translationMeta->rootEntityName ; | |
+ | |
$qb = $this->_em->createQueryBuilder(); | |
$qb->select('trans.content, trans.field, trans.locale') | |
- ->from($translationMeta->rootEntityName, 'trans') | |
+ ->from($translationClass, 'trans') | |
->where('trans.foreignKey = :entityId', 'trans.objectClass = :entityClass') | |
->orderBy('trans.locale'); | |
$q = $qb->getQuery(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I know you have do this a long time ago, but is it still working ?
I found the issue (https://github.com/l3pp4rd/DoctrineExtensions/issues/167) and your patch is not available =/
Is this a good way to do, or there is another way now ?
Thanks