![](/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.