简体   繁体   English

如何在symfony2中更改用户提供者

[英]How to change user provider in symfony2

I changed to use two database in my application. 我更改为在应用程序中使用两个数据库。

Originally, the user authentication was implemented by using the tables of a database named 'A'. 最初,用户身份验证是通过使用名为“ A”的数据库表来实现的。

But I would like to change to the database called B. 但是我想更改为名为B的数据库。

No problem if you want to log in new, but in the case of login Remember Me, an error that there is no user provider will occur. 如果您想重新登录就没问题,但是在登录“记住我”的情况下,将出现一个没有用户提供程序的错误。

Is there a way to avoid this problem? 有办法避免这个问题吗?

an example of the code is following: 代码示例如下:

・app/config/security.yml ・ app / config / security.yml

original 原版的

security:
  providers:
    main:
      entity: { class: Acme¥DemoBundle¥Entity¥User }

changed 变了

security:
  providers:
    main:
      entity: { class: Acme¥NewDemoBundle¥Entity¥NewUser }

Do you use two different EntityManagers? 您是否使用两个不同的EntityManager?

Perhaps using the manager_name config option: 也许使用manager_name config选项:

security:
  providers:
    main:
      entity: 
          class: Acme¥NewDemoBundle¥Entity¥NewUser 
          manager_name: entity_manager_name_for_database_B

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM