首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Stof/Gedmo转换映射异常

使用Stof/Gedmo转换映射异常
EN

Stack Overflow用户
提问于 2012-08-17 07:20:15
回答 2查看 1.2K关注 0票数 1

我正在将Symfony 2.0项目迁移到2.1rc1版本。在安装stof/doctrine-extensions-bundlegedmo/doctrine-extensions并测试我的应用程序之后,我得到以下错误:

没有为"Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation".的实体"Company\TestBundle\ Entity \PageTranslation“子类指定标识符/主键每个实体都必须有一个标识符/主键。

我的config.yml看起来是这样的:

代码语言:javascript
复制
# 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                             

根据StofDoctrineExtensionsBundle的说法,这应该是可以的。我唯一不确定的是auto_mapping: true选项。

我在项目中更改的唯一代码是在我的CategoryTranslation class中。我已经取代了:

代码语言:javascript
复制
use Stof\DoctrineExtensionsBundle\Entity\AbstractTranslation;

出自:

代码语言:javascript
复制
use Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation;

因为Stof-bundle不再有AbstractTranslation类了。

谁能告诉我怎么解决这个问题吗?

EN

回答 2

Stack Overflow用户

发布于 2012-08-19 17:58:05

我的PageTranslation实体之前:

代码语言:javascript
复制
class PageTranslation extends AbstractTranslation
{
    /**
     * All required columns are mapped through inherited superclass
     */
}

在生成命令行上的实体之后,我的PageTranslation实体:

代码语言:javascript
复制
class PageTranslation extends AbstractTranslation
{
    /**
     * All required columns are mapped through inherited superclass
     */

    /**
     * @var integer $id
     */
    private $id;

    /**
     * @var string $locale
     */
    private $locale;

    .....etc....

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set locale
     *
     * @param string $locale
     * @return PageTranslation
     */
    public function setLocale($locale)
    {
        $this->locale = $locale;

        return $this;
    }

    /**
     * Get locale
     *
     * @return string 
     */
    public function getLocale()
    {
        return $this->locale;
    }

    ..etc....
}
票数 0
EN

Stack Overflow用户

发布于 2013-01-26 23:50:36

如果您正在使用StofDoctrineExtensions,则不需要gedmo/doctrine-extensions。在PageTranslation中生成任何东西也不需要

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12001460

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档