简体   繁体   中英

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.

But there are a few questions that still remains for me about Sonata and the way it works and can be customized.

Here are they :

  • Is it possible to use a custom controller to display the Dashboard "home"?
  • 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. Is it possible? Screen to explain more : 在此处输入图片说明

    If yes, if anyone has hints about how to do this, they are welcome! :)

  • Using this roles means managing the rights of these ones on my objects / controller. Is there any mechanism bundled for that or do I have to add mine?

In symfony you can customize third party bundle by inheriting that bundle. So to use your own controller do the followings step by step:

In your custom bundle: AcmeDemoBundle.php add:

public function getParent()
{
    return 'SonataAdminBundle';
}

Now your bundle is inheriting SonataAdminBundle .

In your custom controller: AcmeDemoBundleCustomController.php

class CustomController extends CoreController {

  public function dashboardAction()
  {
      ...
      /* Here goes your code */
  }

}

Turdaliev's answer is the correct way for your first question.

Regarding the roles, those displayed are those present in your application's security.yml file :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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