![](/img/trans.png)
[英]how to add user roles dynamically upon login with symfony2 (and fosUserBundle)?
[英]How to add custom fields to some user roles in the Symfony2 FOSUserBundle?
我遇到的情况是,我的Web应用程序的“用户”有3个角色-Mentor , Mentee和Supervisor 。 我已经了解了如何使用FOSUserBundle来管理用户并使用ROLE_
前缀分配角色。 但是,我还想存储一些特定于特定角色的额外信息,例如,Mentors joindate
sessionscompleted
并且完成了sessionscompleted
,而Supervisor joindate
有了salary
。 我可以为每个角色创建3个单独的实体,并在必要时添加其他字段。 但是,在我项目的config.yml文件中设置FOSUserBundle时,它只具有指定一个实体的空间:
app/config/config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: AppBundle\Entity\Mentor **# how do I specify the other 2 entities here?**
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.