gedmo学说可翻译的扩展。检索所有翻译或特定翻译(与当前区域设置不同)

时间:2013-06-14 11:07:00

标签: symfony doctrine-orm locale doctrine-extensions

我有一个使用gedmo doctrine可翻译扩展的实体。 我可以在当前语言环境中加载此实体。

现在,对于我希望用户查看和编辑各种翻译的管理面板,我想显示所有翻译或用户选择的特定翻译。

我在该实体上只有 - > getTranslations方法。加载选择翻译还有另外一个技巧吗? 对于给定的场景,是否有最佳实践?

非常感谢!

1 个答案:

答案 0 :(得分:0)

我解决了从实体"翻译库"中检索翻译的问题。并传递给表单模型(我为处理翻译而创建的模型):

$nodeRepository = $this->getDoctrine()->getRepository('AcmeCoreBundle:Node');
$node = $repository->find($id);

$translationsRepository = $this->getDoctrine()>getRepository('Acme\CoreBundle\Entity\NodeTranslation');

// retrieving the translations for the given node
$translations = $repository->findTranslations($node);

$model = new TranslatableModel($node, $translations, ...);

我希望这会对某人有所帮助......