1

您好想使用 Doctrine Extensions ins Symfony2 中的可翻译行为。

我使用 Doctrine,在尝试了自己的课程后,我 100% 复制了 Article 课程

http://gediminasm.org/article/translatable-behavior-extension-for-doctrine-2

在我的项目中,只调整了命名空间。但我得到一个例外:

[2/2] DBALException: An exception occurred while executing 'SELECT t0.id AS id1, t0.title AS title2, t0.content AS content3 FROM articles t0 WHERE t0.id = ?' with params {"1":1}:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.content' in 'field list'

发送的 MySql 查询是

    SELECT t0.id AS id1, t0.title AS title2, t0.content AS content3 FROM articles t0 WHERE t0.id = 1

为什么 Doctrine/Symfony 尝试访问文章而不是 ext_translations。如果我使用 TranslationEntity,一切正常,所以我确信可翻译已在我的配置中激活。但这是我的配置,让一切都清楚

配置.yml

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver:   %database_driver%
                host:     %database_host%
                port:     %database_port%
                dbname:   %database_name%
                user:     %database_user%
                password: %database_password%
                charset:  UTF8
                mapping_types:

    orm:
        auto_generate_proxy_classes: %kernel.debug%
        default_entity_manager: default
        entity_managers:
            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
                    gedmo_loggable:
                        type: annotation
                        prefix: Gedmo\Loggable\Entity
                        dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
                        alias: GedmoLoggable # this one is optional and will default to the name set for the mapping
                        is_bundle: false
                    gedmo_tree:
                        type: annotation
                        prefix: Gedmo\Tree\Entity
                        dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
                        alias: GedmoTree # this one is optional and will default to the name set for the mapping
                        is_bundle: false

stof_doctrine_extensions:
        default_locale: en_us
        translation_fallback: true
        orm:
            default:
              timestampable: true
              translatable: true
              sluggable: true

有谁知道为什么这不起作用?非常感谢你的帮助

4

0 回答 0