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