Hide download button in sonata admin

我只是一个虾纸丫 提交于 2019-12-11 00:13:59

问题


I would like to hide "Download" button on Sonata Admin from some of custom entity. How to hide/delete it?

If i override base_list.html.twig and remove the download button from table_footer, it disappears all of entity lists. Is there any way to hide it from Admin class?


回答1:


You can hide the "download" button by removing the corresponding route:

class YourClass extends AbstractAdmin {

  public function configureRoutes(RouteCollection $collection) {
    $collection->remove('export');
  }
}



回答2:


PROBLEM SOLVED!

I solved it by managing user roles. For example:

You want to remove Download button in Post section. So you need to add below code in app/config/security.yml

security:
    role_hierarchy:
        ROLE_PUBLISHER:
            - ROLE_ADMIN_POST_CREATE
            - ROLE_ADMIN_POST_EDIT
            - ROLE_ADMIN_POST_LIST
            - ROLE_ADMIN_POST_VIEW
            - ROLE_ADMIN_POST_EXPORT #If you comment or delete this line. Download button don't show in Sonata Post List.


来源:https://stackoverflow.com/questions/38734213/hide-download-button-in-sonata-admin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!