Remove the default block sonata.admin.block.admin_list in SonataAdminBundle.

When using SonataAdminBundle and SonataBlockBundle, I wanted to remove the default block.

It doesn't provide much benefit, as it simply duplicates the functionality of the side menu on the dashboard.

When installing SonataBlockBundle, if we simply write in the configuration:

sonata_block:
    default_contexts: [sonata_page_bundle]
    blocks: []

(in the future we will add our own blocks, but for now we just leave an empty array), we will catch an error.

An exception has been thrown during the rendering of a template ("The block type "sonata.admin.block.admin_list" does not exist") in SonataAdminBundle:Core:dashboard.html.twig at line 35.

At first, it may seem that we need to configure the block sonata.admin.block.admin_list (the one that is actually displayed on the dashboard).

But if we simply want to remove it, it turns out that we just need to configure the displayed blocks in SonataAdminBundle itself. We will get something like:

 

sonata_admin:
    dashboard:
        blocks: []

sonata_block:
    default_contexts: [sonata_page_bundle]
    blocks: []

We get an empty dashboard and an understanding of how to manage blocks. To add a block, you need to configure it like this:

sonata_block:
    default_contexts: [sonata_page_bundle]
    blocks:
        service_id:


sonata_admin:
    dashboard:
        blocks:
            -
              position: left
              type: service_id

where service_id is the id of your block service. It's strange, of course, that you need to configure the block twice, but the first time (in sonata_block) you configure the block itself, and in sonata_admin - its display on the dashboard.