简体   繁体   中英

Sonata admin overwrite service configuration

I have the sonata admin bundle installed with the notifications bundle from the same vendor. However I don't want to display the notification bundle on the admin panel.

I know that, in order to do this, I can use:

show_in_dashboard="false"

I have placed it on the vendor folder and it works but I wanted to place it on the config.yml so it doesn't cause problems between server or version updates.

Any idea on how to do this?

For whom may care the normal syntax to disable the presentation is:

<tag
                    name="sonata.admin"
                    manager_type="orm"
                    group="sonata_notification"
                    label="notifications"
                    label_translator_strategy="sonata.admin.label.strategy.underscore"
                    show_in_dashboard="false"
               />

or in yml:

tags:
            - { name: sonata.admin, manager_type: orm, group: "Some Group", label: "", show_in_dashboard: false }

Thanks

The way I solve this problem is by specifying explicitly in sonata_admin config which admin services to display in dashboard.

sonata_admin:
dashboard:
    blocks:
        # display a dashboard block
        - { position: left, type: sonata.admin.block.admin_list }

    groups:
        some_group:
          label:  "Some group"
          items:
            - some_admin_service
            - some_other_admin_Service
        some_other_group:
          label:  "Some other group"
          items:
            ...

Some more examples can be found in documentation http://sonata-project.org/bundles/admin/2-1/doc/reference/dashboard.html

You can override services definition using services.yml (in your case).

1) Create file (if it not exists): app/config/services.yml

2) In config.yml in section "imports" add new source:

imports:
- { resource: parameters.yml }
- { resource: services.yml }

3) Add service definition with

show_in_dashboard: false

It'll override defaults from vendor

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