简体   繁体   English

Sonata用户捆绑包:管理许多类别的用户

[英]Sonata User Bundle: Managing many categories of users

I'm working on a Symfony 2.8 based project, I installed Sonata Admin Bundle and User Bundle and all is working perfectly. 我正在开发一个基于Symfony 2.8的项目,我安装了Sonata Admin Bundle和User Bundle,并且一切运行正常。

I have a customized register and profile pages, and the users are well managed by the admin dashboard and all is at top. 我有一个自定义的注册和配置文件页面,用户通过管理仪表板进行了很好的管理,所有操作都位于顶部。 But, a new feature just appeared. 但是,一个新功能刚刚出现。 So the users were meant to be University Professors, so I added all the fields necessary for representing them. 因此,用户原本是大学教授,所以我添加了代表他们的所有必填字段。 But now they want also students to be able to register in the application, and be managed by admin dashboard as well. 但是现在,他们还希望学生能够在应用程序中注册,并由管理仪表板进行管理。 Do you have any ideas what will be the best way to separate the students from the professors, they will both have a lot of fields in common. 您有什么想法将学生与教授区分开来的最佳方法是什么,他们将有很多共同点。 In fact, I just need a flag (student or not). 实际上,我只需要一个标志(是否为学生)。 But how will they appear in distinct lists in the admin dashboard ? 但是它们将如何出现在管理仪表板的不同列表中? I'm thinking about groups but I'm not sure how to affect a user to a group when registering. 我正在考虑网上论坛,但不确定在注册时如何影响用户加入网上论坛。

Thank you 谢谢

If all you need is a flag, you can add it (lets just say you call it isProfessor), then add a datagrid filter on that flag. 如果您只需要一个标志,则可以添加它(只说您叫它isProfessor),然后在该标志上添加一个数据网格过滤器。

This will allow you to filter on whether isProfessor is true or not. 这将允许您筛选isProfessor是否为true。

https://sonata-project.org/bundles/admin/master/doc/reference/action_list.html#filters https://sonata-project.org/bundles/admin/master/doc/reference/action_list.html#filters

If you want specific lists of professors/students you could create a custom list view for each: 如果您想要特定的教授/学生列表,则可以为每个人创建一个自定义列表视图:

https://sonata-project.org/bundles/admin/master/doc/cookbook/recipe_custom_action.html https://sonata-project.org/bundles/admin/master/doc/cookbook/recipe_custom_action.html

Should be pretty straightforward. 应该很简单。

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

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