Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add correct link into admin main menu #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mattusik
Copy link

@mattusik mattusik commented May 16, 2024

Hi, I've created this PR because I am not able to extend REMP menu without this change.

I am trying to add Beam and Campaigner links into the remp menu using this snippet in my module:

    public function registerAdminMenuItems(MenuContainerInterface $menuContainer)
    {
        $mainMenu = new MenuItem($this->translator->translate('remp_mailer.menu.main'), '#remp', 'fa fa-rocket', 749, false);

        $menuItem = new MenuItem('Beam', Core::env('REMP_BEAM_HOST'), 'fa fa-envelope', 2010, false);
        $menuContainer->attachMenuItemToForeignModule('#remp', $mainMenu, $menuItem);
        
        $menuItem = new MenuItem('Campaigner', Core::env('REMP_CAMPAIGNER_HOST'), 'fa fa-envelope', 2020, false);
        $menuContainer->attachMenuItemToForeignModule('#remp', $mainMenu, $menuItem);
    }

but it seems to be impossible without provided change.

@rootpd
Copy link
Member

rootpd commented May 16, 2024

You're doing this almost correct, try this in your module.

$mainMenu = new MenuItem(
    $this->translator->translate('remp.admin.menu.default'),
    '#remp',
    'fa fa-rocket',
    750,
    false
);

$menuItem = new MenuItem('Campaign', Core::env('REMP_CAMPAIGNER_HOST'), 'fa fa-chart-line', 2001, false);
$mainMenu->addChild($menuItem);

$menuItem = new MenuItem('Beam', Core::env('REMP_BEAM_HOST'), 'fa fa-space-shuttle', 2002, false);
$mainMenu->addChild($menuItem);

$menuContainer->attachMenuItem($mainMenu);

The idea is that:

  • Mailer by default registers itself as a main menu item.
  • If you register #remp menu item (the thing you did in your snippet):
    • Mailer will move itself as subitem into your main menu item.
    • Beam/Campaign/something else menu subitems will be registered by you.

So instead of attaching Beam/Campaign items to the foreign module menu items, just attach them to your menu item and let Mailer's subitem join the party 🙂 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants