[英]Customize Sonata-admin dashboard “home”
I'm quite new to the Sonata project, and as "playing" with it, I wanted to use it for one of my projects. 我对Sonata项目很陌生,在“玩”它时,我想将其用于我的一个项目。
But there are a few questions that still remains for me about Sonata and the way it works and can be customized. 但是,关于Sonata以及它的工作方式和可定制的问题,还有一些问题对我来说仍然存在。
Here are they : 他们是:
I'd like to use roles and only roles to manage my security but can't figure out how to add Roles to the list that is displayed when you use the users creation form (by default located at /admin/my/bundle/user/create
) under the "management" tab. 我想仅使用角色来管理我的安全性,但无法弄清楚如何在使用用户创建表单时将角色添加到显示的列表中(默认位于
/admin/my/bundle/user/create
)在“管理”标签下。 Is it possible? 可能吗? Screen to explain more :
屏幕说明更多:
If yes, if anyone has hints about how to do this, they are welcome! 如果是的话,如果有人对如何做有任何提示,欢迎他们! :)
:)
In symfony you can customize third party bundle by inheriting that bundle. 在symfony中,您可以通过继承第三方捆绑软件来定制该捆绑软件。 So to use your own controller do the followings step by step:
因此,要使用您自己的控制器,请按以下步骤操作:
In your custom bundle: AcmeDemoBundle.php
add: 在您的自定义包中:
AcmeDemoBundle.php
添加:
public function getParent()
{
return 'SonataAdminBundle';
}
Now your bundle is inheriting SonataAdminBundle
. 现在,您的捆绑包继承了
SonataAdminBundle
。
In your custom controller: AcmeDemoBundleCustomController.php
在您的自定义控制器中:
AcmeDemoBundleCustomController.php
class CustomController extends CoreController {
public function dashboardAction()
{
...
/* Here goes your code */
}
}
Turdaliev's answer is the correct way for your first question. Turdaliev的答案是第一个问题的正确方法。
Regarding the roles, those displayed are those present in your application's security.yml file : 关于角色,显示的角色是应用程序的security.yml文件中存在的角色:
security:
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH, ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT, ROLE_SONATA_PAGE_ADMIN_BLOCK_EDIT]
In Sonata, an ACL mechanism is implemented, adding new roles for various actions such as view, delete, ... You may see a detailed example in the demo ( https://github.com/sonata-project/sandbox ), checkout the SonataAdmin security documentation for more details: http://sonata-project.org/bundles/admin/master/doc/reference/security.html 在Sonata中,实现了ACL机制,为各种操作(例如查看,删除等)添加了新角色。您可能会在演示( https://github.com/sonata-project/sandbox ),结帐中看到详细的示例。有关更多详细信息,请参见SonataAdmin安全文档: http ://sonata-project.org/bundles/admin/master/doc/reference/security.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.