Error after Upgrading FOS UserBundle from 1.2 to 2.0 in Symfony 2.1

给你一囗甜甜゛ 提交于 2019-12-10 17:34:50

问题


I have a project in Symfony 2.1, with PropelBundle, and FOS UserBundle. I upgraded FOS UserBundle with Composer from 1.2 to the latest version (2.0) and followed the instruction to delete the "propel_user_class" definition in the app/config/config.yml file as indicated in the Upgrade.md file. My new config is as follows:

# FOSUserBundle Configuration
fos_user:
    db_driver: propel
    firewall_name: main
    user_class: MyVendor\MyBundle\Model\Member
    registration:
        form:
            type: myvendor_user_registration

After doing so and rebuilding the model, I get the following error when submitting the user login form: "The user provider must return a UserInterface object."

I think there is an issue with the FOS UserBundle not recognizing my user class "Member" and its properties. In FOS/UserBundle's earlier version (1.2) the FOS\UserBundle\Model\UserInterface was implemented by a proxy object, thus my previous config (which was working) included the following:

user_class: MyVendor\MyBundle\FOSUserBundle\Propel\UserProxy
propel_user_class: MyVendor\MyBundle\Model\Member

My UserProxy.php file used to extend FOS\UserBundle\Propel\UserProxy and add the properties that were specific to my project. Is that UserProxy.php no longer needed with the new UserBundle version? What else do I have to do to make the new UserBundle version work? The above mentioned Upgrade.md file also talks about the profile form no longer wrapping the user in a CheckPassword class, and the generation of the token not being done by the User class anymore. However, I'm not sure whether I have to do any changes because of that? Could anyone give me some guidelines?

I tried to move my Member, Circle, and MemberCircle classes definition Schema to app/Resources/FOSUserBundle/config/propel/schema.xml to override the schema inside FOS User Bundle as indicated in the documentation, while telling the classes in my own bundle to extend the ones in FOS UserBundle but I get the following error when trying to build the propel model with "app/console propel:build":

[RuntimeException]
"MyProjectName/app/Resources/FOSUserBundle/config/propel/schema.xml" resource is hidden by a resource from the "MyBundle" derived bundle. Create a "MyProjectName/app/Resources/MyBundle/config/propel/schema.xml" file to override the bundle resource.

I kept the namespace "FOS\UserBundle\Propel" in the app/Resources/FOSUserBundle/config/propel/schema.xml file. How can I make that schema override the one in FOS/UserBundle? Can I use classes named "Member" (for User) and "Circle" (for Group) in it?

来源:https://stackoverflow.com/questions/11837636/error-after-upgrading-fos-userbundle-from-1-2-to-2-0-in-symfony-2-1

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