我正在將我的Symfony 2.0項目遷移到版本2.1rc1。安裝stof/doctrine-extensions-bundle
和gedmo/doctrine-extensions
和測試我的應用程序後,我收到以下錯誤:使用Stof/Gedmo Translation映射異常
No identifier/primary key specified for Entity "Company\TestBundle\Entity\PageTranslation" sub class of "Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation". Every Entity must have an identifier/primary key.
我config.yml
看起來是這樣的:
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
orm:
auto_generate_proxy_classes: %kernel.debug%
connection: default
auto_mapping: true
mappings:
gedmo_translatable:
type: annotation
prefix: Gedmo\Translatable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
alias: GedmoTranslatable # this one is optional and will default to the name set for the mapping
is_bundle: false
gedmo_translator:
type: annotation
prefix: Gedmo\Translator\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
alias: GedmoTranslator # this one is optional and will default to the name set for the mapping
is_bundle: false
stof_doctrine_extensions:
default_locale: en
translation_fallback: true
orm:
default:
translatable: true
sluggable: true
按照documentation of StofDoctrineExtensionsBundle
這應該是罰款。唯一我不確定的是auto_mapping: true
選項。
我在項目中更改的唯一代碼是我的CategoryTranslation class
。我把它換成:
use Stof\DoctrineExtensionsBundle\Entity\AbstractTranslation;
由:
use Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation;
由於STOF束不具有AbstractTranslation
類了。
有人能告訴我如何解決這個問題嗎?
OK生成什麼,所以顯然我的翻譯機構也正在處理:生成:命令行上的實體 。那麼,如何設置我的映射來防止這種情況發生? – Rick 2012-08-17 14:50:02
請添加PageTranslation類/映射 – AdrienBrault 2012-08-18 14:48:20