0
我使用学说2与behavioral-extensions(尤其是树,Sluggable和翻译的)如何创建一个新的实体
的过程中插入多个译本在这些例子中一个新的翻译时,首先存储商品制造,找到它,然后进行翻译。
// first load the article
$article = $em->find('Entity\Article', 1 /*article id*/);
$article->setTitle('my title in de');
$article->setContent('my content in de');
$article->setTranslatableLocale('de_de'); // change locale
$em->persist($article);
$em->flush();
是否有可能创建一篇文章连同它的翻译?
我已经试过
//assuming the translationListener has default locale en_us
$article = new Article;
$article->setTitle('my title in en_us');
$article->setContent('my content in en_us');
$em->persist($article);
$article->setTranslatableLocale('de_de')
$article->setTitle('my title in german');
$article->setContent('my content in german');
$em->persist($article);
$em->flush();
但是,这导致了两个物品表和翻译表德国的内容。
如何在创建新实体期间插入多个翻译?
编辑:我的坏。没有阅读文档。 (我不确定我是否理解,为什么有更新和持久化同一个对象两次会将单独的数据写入两个不同的表?) – 2011-01-06 17:11:08