Use FOSUserBundle in relation with yml-based Entities

别来无恙 提交于 2019-11-30 14:41:50

The problem you describe stems from mixing configuration formats (yaml and I assume annotations). You can easily fix this by ditching the annotations in your models and replacing them with yaml-files like you would do in your own models.

Unfortunately the FOSUserBundle-docs only show you how to use annotations, so here is a quick transformation into yaml format when your X\MyBundle\Entity\User extends FOSUSerBundle's UserEntity:

X\MyBundle\Entity\User:
    type:  entity
    table: fos_user
    id:
        id:
            type: integer
            strategy: { generator: "AUTO" }

The remaining stuff is taken care of by FOSUserBundle, as the BaseModel is a mapped-superclass and already describes the stuff in the User.orm.xml, but you could just as well replace the existing values or add additional values just like you would do with your own models.

If you don't use annotations throughout your app, you might also want to disable them in your app/config/config.yml to prevent side effects.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!