FOSUserBundle与多个实体经理 - Symfony 2设置 [英] FOSUserBundle with multiple entity managers - Symfony 2 set up

查看:226
本文介绍了FOSUserBundle与多个实体经理 - Symfony 2设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用FOSUserBundle和FOSOAuthBundle在项目中没有问题,但最近我添加了另一个DB连接和另一个实体管理器,结果不再依赖于auto_mapping。 / p>

我已将两个捆绑包的映射添加到其中一个实体管理器,一切似乎都可以正常工作。



但是,当运行 app / console doctrine:schema:create 时,用户不再生成正确的架构,这表明存在映射问题。值得注意的是,来自FOSOAuthBundle的客户端正在映射OK。



看起来,FOSUserBundle中的映射被忽略,我不知道我是什么执行错误。



实体管理器设置:

  orm:
default_entity_manager:默认
auto_generate_proxy_classes:%kernel.debug%

entity_managers:
其他:
连接:其他
映射:
SteveMainBundle:〜
默认值:
连接:默认
映射:
SteveMainBundle:〜
SteveWebBundle:〜
FOSUserBundle:〜
FOSOAuthServerBundle:〜

fos_user设置:

  fos_user:
db_driver:orm
firewall_name:main
user_class:Steve\MainBundle\Entity\User

任何想法?

解决方案

您可以通过

$ b设置自定义实体管理器
$ b

  model_manager_name 

选项。 查看文档


I've been using the FOSUserBundle and the FOSOAuthBundle without issue in a project for a while now, but I've recently added another DB connection and another entity manager and, as a result, can no longer rely on auto_mapping.

I've added mapping for both of the bundles to one of the entity managers and everything seemed to be working OK.

However I've found an issue with the User no longer generating the correct schema when running app/console doctrine:schema:create, suggesting a mapping issue. It's worth noting that the client from FOSOAuthBundle is mapping OK.

It looks to me that the mapping in the FOSUserBundle is being ignored and I'm not sure what I'm doing wrong.

Entity Manager set up:

orm:
    default_entity_manager: default
    auto_generate_proxy_classes: %kernel.debug%

    entity_managers:
        other:
            connection: other
            mappings:
                SteveMainBundle: ~
        default:
            connection: default
            mappings:
                SteveMainBundle: ~
                SteveWebBundle: ~
                FOSUserBundle: ~
                FOSOAuthServerBundle: ~

fos_user set up:

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: Steve\MainBundle\Entity\User

Any ideas?

解决方案

You can set a custom entity manager by

model_manager_name

option. Look into documentation

这篇关于FOSUserBundle与多个实体经理 - Symfony 2设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆