serBundle或PUGXMultiUserBundle具有两

serBundle或PUGXMultiUserBundle具有两

本文介绍了FOSUserBundle或PUGXMultiUserBundle具有两个不同的用户配置文件(Symfony2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对如何解决此问题表示怀疑:

I'm doubtful about how to approach this problem:

针对此问题的我的Symfony2应用具有两个不同的配置文件,名称分别为卖方"和买方".目标是保留有关卖方"的一堆属性,另一方面,对买方"的保留不多(电子邮件和密码即可).

My Symfony2 app for this issue has two different profiles, name 'em "Seller" and "Buyer". The goal is to keep a bunch of attributes about a "Seller", and, on the other hand, not much about the "Buyer" (email and password would do it).

我意识到让两个不同的实体使用FOSUserBundle登录并注册并不容易.还有很多其他捆绑软件,例如PUGXMultiUserBundle可以破解" FOSUserBundle,并且不容易配置/实现.

I realise that it's not easy to have two different entities log in and register using FOSUserBundle. There are quite some other bundles, such as PUGXMultiUserBundle that 'hack' FOSUserBundle, and are not easy to config/implement.

所以我的问题是:使用PUGXMultiUserBundle提出的技巧,处理其实现和配置更正确,还是坚持使用FOSUserBundle,拥有一个User实体以及与一个一对一的关系更好? 卖方"实体代表卖方的属性与买方的属性不同吗?对于卖方和买方进行注册,这种方法的另一个问题是注册表格,应该分为两部分(我不知道是否可以/建议使用FOSUserBundle)

So my quiestion is: Is it more correct to use the hack PUGXMultiUserBundle proposes, dealing with its implementation and config, or is it better to stick to FOSUserBundle, have a User entity, and a one-to-one relation with a "Seller" entity that represents the attributes of a Seller different from a buyer? There would be another problem with that approach, with the registration form, that should be splitted in two, for Seller and Buyer register (which I don't know if it is possible/advisable using FOSUserBundle)

希望大家帮我弄对.欢呼声:)

I hope you guys help me get it right. Cheers :)

推荐答案

为此,我一定会使用 PUGXMultiUserBundle .我不认为这是黑客,它只是实现了一个歧视表,如下所示:

I would definitely use the PUGXMultiUserBundle for that. I don't think it's a hack, it just implements a discrimination table that will be like:

用户表

----------------------------------------
| id  | username  |  type  |------------
|-----|-----------|--------|------------
|  1  |  mgdepoo  | buyer  |------------
|  2  | Sydney_o9 | seller |------------
----------------------------------------

买方表

----------------------------------------
| id  |  buyer_specific_field_1
|-----|---------------------------------
|  1  |
----------------------------------------

卖方表

----------------------------------------
| id  |  seller_specific_field_1
|-----|---------------------------------
|  2  |
----------------------------------------

这就是全部.

我认为这正是您所需要的,尤其是如果您希望为用户提供不同的个人资料.您还将有2个注册表格(但如果您愿意,可以与选择框买方/卖方制作一张注册表格).

I think that's exactly what you need especially if you wish to have different profiles for your users. You will have 2 registration forms as well (but you can make one with a choice box buyer/seller if you want to).

我个人使用了此捆绑包,它对我来说非常有用.现在,您可能要问自己的一个问题是,如果买方也想同时成为卖方,该怎么办.他是否想要另一个电子邮件地址?这是您必须做出的选择.

I personally use this bundle and it works great for me. Now, one of the question you might want to ask yourself is what if a buyer wants to be a seller as well. Does he want to have another email address? That is a choice that you'll have to make.

这篇关于FOSUserBundle或PUGXMultiUserBundle具有两个不同的用户配置文件(Symfony2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 05:35