diff --git a/app/Menu/AdminMenuBuilder.php b/app/Menu/AdminMenuBuilder.php index 689d1cf7..c16260c6 100644 --- a/app/Menu/AdminMenuBuilder.php +++ b/app/Menu/AdminMenuBuilder.php @@ -47,7 +47,7 @@ private function addLibrarySubMenu(ItemInterface $menu): void $library = $menu ->addChild('library') ->setLabel('app.ui.library') - ->setLabelAttribute('icon', 'tabler:users') + ->setLabelAttribute('icon', 'tabler:books') ; $library->addChild('books', ['route' => 'app_admin_book_index']) diff --git a/docs/.gitbook/assets/sidebar_menu.png b/docs/.gitbook/assets/sidebar_menu.png new file mode 100644 index 00000000..27ea8833 Binary files /dev/null and b/docs/.gitbook/assets/sidebar_menu.png differ diff --git a/docs/.gitbook/assets/submenu_items.png b/docs/.gitbook/assets/submenu_items.png new file mode 100644 index 00000000..fb4d105b Binary files /dev/null and b/docs/.gitbook/assets/submenu_items.png differ diff --git a/docs/cookbook/admin_panel/menu.md b/docs/cookbook/admin_panel/menu.md index 8d3ee36f..25137c7c 100644 --- a/docs/cookbook/admin_panel/menu.md +++ b/docs/cookbook/admin_panel/menu.md @@ -2,6 +2,14 @@ ## How to customize the sidebar menu +### Decorate the sidebar menu + +
+ +
Sidebar menu
+ +
+ To customize the admin menu, you need to decorate the `sylius_admin_ui.knp.menu_builder` service. ```php @@ -38,3 +46,46 @@ final readonly class MenuBuilder implements MenuBuilderInterface } } ``` + +### Add submenu items + +
+ +
Submenu items
+ +
+ +Now you can add submenu items: + +```php +#[AsDecorator(decorates: 'sylius_admin_ui.knp.menu_builder')] +final readonly class MenuBuilder implements MenuBuilderInterface +{ + // ... + + public function createMenu(array $options): ItemInterface + { + $menu = $this->factory->createItem('root'); + + // ... + + $this->addLibrarySubMenu($menu); + + return $menu; + } + + private function addLibrarySubMenu(ItemInterface $menu): void + { + $library = $menu + ->addChild('library') + ->setLabel('app.ui.library') + ->setLabelAttribute('icon', 'tabler:books') + ; + + $library->addChild('books', ['route' => 'app_admin_book_index']) + ->setLabel('app.ui.books') + ->setLabelAttribute('icon', 'book') + ; + } +} +```