Skip to content
This repository was archived by the owner on May 28, 2026. It is now read-only.

Latest commit

 

History

History
151 lines (110 loc) · 4.92 KB

File metadata and controls

151 lines (110 loc) · 4.92 KB

Menu


?> By default, the menu is generated automatically. One menu item will be created for each detected Crud Controllers, and they will be sorted alphabetically.

You can however change how it's done, and even add child items.

Overriding the menu through yaml

in config/qag.yaml (if there is no file, create one), add the following:

arkounay_quick_admin_generator:
    menu:
        items:
            - App\Controller\NewsController
            - App\Controller\CategoryController
            - crud: App\Controller\Admin\AgencyController
              label: 'Item with subitems'
              children:
                - App\Controller\UserController
                - { label: 'google', url: 'https://www.google.com', target: '_blank' }
            # etc...
  • Items specifying a crud controller will still be hidden when their controller's isEnabled returns false, and still behave as usual.
  • If a crud isn't specified, you can specifiy how an item is renderer through the label, url, route, route_params, target and attr attributes
  • The children attribute allows adding submenu items.

Menu

Overriding the menu by service

Create a class that implements MenuInterface (or extends Menu). The easiest way is to extend Menu, and add the proper configuration in services.yaml

    Arkounay\Bundle\QuickAdminGeneratorBundle\Menu\MenuInterface: '@App\Admin\Menu'

    App\Admin\Menu:
        arguments:
            $cruds: !tagged_iterator quickadmin.crud
            $config: '%quick_admin_generator%'
namespace App\Admin;

use Arkounay\Bundle\QuickAdminGeneratorBundle\Menu\Menu as BaseMenu;
use Arkounay\Bundle\QuickAdminGeneratorBundle\Menu\MenuItem;
use Symfony\Component\HttpFoundation\Request;

class Menu extends BaseMenu
{

    protected function createMenuItem(array $cruds, $node, Request $request): ?MenuItem
    {
        $menuItem = parent::createMenuItem($cruds, $node, $request);
        // $node will be a crud class or will contain what's in the arkounay_quick_admin_generator.menu.items yaml definition
        return $menuItem;
    }
    
    protected function createDashboardMenuItem(Request $request): ?MenuItem
    {
        // returning Null will remove the Dashboard item
        return null;
    }

}

Overriding the menu through twig

Create the file /templates/bundles/ArkounayQuickAdminGeneratorBundle/base.html.twig In it, you can override the block menu_items and do what you want there.

{% extends '@!ArkounayQuickAdminGenerator/base.html.twig' %}

{% block menu_items %}
{% endblock %}

If you want to configure how the dashboard item looks, you can override the block menu_items_dashboard.

Changing the menu orientation

By default, the menu is horizontal.

Horizontal Menu

You can make it vertical by editing the yaml:

arkounay_quick_admin_generator:
    menu:
        theme: 'vertical'

Vertical Menu

Changing the title

You can change the title by editing the arkounay_quick_admin_generator.title

arkounay_quick_admin_generator:
    title: 'Custom Title'

or override the twig block main_title for more control.

Enabling global search

You can enable global search by setting arkounay_quick_admin_generator.global_search to true

arkounay_quick_admin_generator:
    global_search: true

You can modify the results with the qag.events.quick_search_item and qag.events.quick_search_crud events.

Switch to dark Mode

You can allow users to switch to dark mode, or set it as default:

arkounay_quick_admin_generator:
    theme:
        default: 'light' # either light / dark / or auto. (auto checks user's preference)
        allow_switch: true # will display a toggle to change the theme on user menu

When switching mode, a customer event theme-switch will be dispatched on the <body>.

Redirect to a specific route instead of the Dashboard

This will redirect to a specified route instead of the Dashboard, and will remove the Dashboard menu item automatically:

arkounay_quick_admin_generator:
    dashboard_route_redirection: 'qag.news'