与FOSUserBundle的关系

时间:2013-09-10 13:21:39

标签: php symfony doctrine-orm fosuserbundle

如何与FOSUserBundle建立关系? FOS在我的项目中运作良好。现在我创建我的包NewsBundle。在NewsBundle/Resources/config/doctrine/News.orm.yml我输入:

Josh\NewsBundle\Entity\News:
    type: entity
    table: news
    id:
        id:
            type: integer
            generator: { strategy: AUTO }
    manyToOne:
        user:
            targetEntity: FOS\UserBundle\Entity\User
            inversedBy: news
            joinColumn:
                name: user_id
                referencedColumnName: id
    fields:
        name:
            type: string
            length: 100

我生成实体(没有错误),我尝试doctrine:schema:update,我收到此错误:

  [Doctrine\ORM\ORMException]
Column name `id` referenced for relation from Josh\NewsBundle\Entity\News towards FOS\UserBundle\Entity\User does not exist.

如何创建与用户的关系?

1 个答案:

答案 0 :(得分:0)

您可以创建自己的用户实体,扩展Fos \ UserBundle \ Model \ User ......这就是我做的......