我正在将我的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