我在「ext_translations」表中包含所有翻譯的表格。具有可翻譯字段的SonataAdminBundle(原則擴展名)
翻譯的作品很棒。現在的問題是:我想通過sonata-admin軟件包管理這些翻譯。
我已經找到了一個文檔,如何獲得與奏鳴曲管理員的工作原則擴展。但在我的情況下,我有一個表/實體我所有的翻譯(對於多個實體)。
所以根據這個文檔:http://www.elao.com/blog/symfony-2/doctrine-2/how-to-manage-translations-for-your-object-using-sonataadminbundle.html什麼應該是我的mappedBy屬性(見下文)?
ext_translations表:
mysql> show columns from ext_translations;
+--------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| locale | varchar(8) | NO | MUL | NULL | |
| object_class | varchar(255) | NO | | NULL | |
| field | varchar(32) | NO | | NULL | |
| foreign_key | varchar(64) | NO | | NULL | |
| content | longtext | YES | | NULL | |
+--------------+--------------+------+-----+---------+----------------+
的mappedBy:
/**
* @ORM\OneToMany(targetEntity="ProfileTranslation", mappedBy="object", cascade={"persist", "remove"})
*/
protected $translations;
據我理解這裏的問題:「我有一個複合鍵(對象類(實體)+名(屬性)+ foreignKey(實體的ID)),那麼'mappedBy'應該如何引用這個?
我不想爲每個可翻譯的實體創建一個額外的類(就像上面的教程)
我不熟悉的SonataAdminBundle,但總體而言學說有什麼問題了「用例1」:http://docs.doctrine-project.org/en/latest/tutorials/composite-primary-keys .html 在這種情況下,Doctrine將處理關係並返回對象的正確翻譯? – Feras