Reputation: 11
Whenever I create a new admin class for an entity in Sonata, the knp side menu creates a new group called "default" with children that corresponds to the entity items. The same goes in the upper navbar when you click on the "plus" icon to display the dropdown menu.
I want to remove this "default" group as it causes duplication when using service decorators (it repeats the decorated admin classes) and it's not pleasant to have (I want to display the items outside of the "default" group in a customized item.)
Take the following case for example:
final class TaskAdmin extends AbstractAdmin {
protected function configureListFields(ListMapper $list): void
{}
protected function configureDatagridFilters(DatagridMapper $filter): void
{}
protected function configureShowFields(ShowMapper $show): void
{}
protected function configureFormFields(FormMapper $form): void
{}
}
App\Admin\TaskAdmin:
tags:
- { name: sonata.admin, model_class: App\Entity\Task, manager_type: orm, label: Task}
final class MenuBuilderListener
{
public function addMenuItems(ConfigureMenuEvent $event): void
{
$menu = $event->getMenu();
}
}
app.menu_listener:
class: App\EventListener\MenuBuilderListener
tags:
- { name: kernel.event_listener, event: sonata.admin.event.configure.menu.sidebar, method: addMenuItems }
N.B: This only happens when I create admin classes (Those admin classes from bundle packages don't fall under the "default" group. Their items are created and well set like SonataMediaBundle which creates a group called "Media Library" with items "Media" and "Gallery").
Upvotes: 1
Views: 60