MenuRegistry

Central registry for managing menus in the backend module document header.

The MenuRegistry is part of the DocHeaderComponent and holds all menus that should be displayed in the module's header area.

Menus are typically used to provide navigation between different views or modes within a module (e.g., switching between list/grid view, or different content types).

Example:

public function __construct(
    protected readonly ComponentFactory $componentFactory,
) }

public function myAction(): ResponseInterface
{
    // Get the menu registry from the module template
    $menuRegistry = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry();

    // Create and configure a menu
    $menu = $this->componentFactory->createMenu();
    $menu->setIdentifier('viewSelector')->setLabel('View');

    // Add menu items
    $listItem = $this->componentFactory->createMenuItem()
        ->setTitle('List')
        ->setHref('/module?view=list')
        ->setActive($currentView === 'list');
    $menu->addMenuItem($listItem);

    // Register the menu
    $menuRegistry->addMenu($menu);
}

Table of Contents

Properties

$menus  : array<string, Menu>
Internal array that stores all registered menus

Methods

addMenu()  : static
Adds a menu to the registry
getMenus()  : array<string|int, Menu>
Returns all menus in an abstract array
makeMenu()  : Menu

Properties

$menus

Internal array that stores all registered menus

protected array<string, Menu> $menus = []

Methods

addMenu()

Adds a menu to the registry

public addMenu(Menu $menu) : static
Parameters
$menu : Menu
Tags
throws
InvalidArgumentException

In case a menu is not valid

Return values
static

getMenus()

Returns all menus in an abstract array

public getMenus() : array<string|int, Menu>
Return values
array<string|int, Menu>

makeMenu()

public makeMenu() : Menu
Deprecated

since v14, will be removed in v15. Use GeneralUtility::makeInstance(Menu::class) directly or inject ComponentFactory and use createMenu().

Return values
Menu

        
On this page

Search results