I am working on a custom Drupal 8 module which generates a menu. Refer Create a new Menu in Drupal 8 programmatically for details.
I have the menu now, but when I try to add custom menu links to it, following add a menu link, somehow it's not getting added to that custom menu.
Another weird thing is that the links are getting added to the wrong menu, i.e. they show under User Account Management
menu.
The only reason I can think of is, when I install the module, Drupal tries to create the menu link first, before it has created custom menu. As the custom menu is not there yet, it tries to add the menu links to another menu. Is that right?
Here is my code, if that helps:
// system.menu.aeauth.yml // This creates the new menu on module install
langcode: en
status: true
dependencies: { }
id: aeauth
label: 'AE Authentication Links'
description: 'Links related to AE Authentication'
locked: true
// ae.links.menu.yml // This adds menu links to menus
ae.admin_settings:
route_name: ae.adminForm
title: 'AE Configuration'
description: 'Configure AE for your website'
parent: system.admin_config_system
ae.register:
title: 'Register'
description: 'Register using AE Connect'
parent: aeauth
route_name: ae.regroute
ae.login:
title: 'Login'
description: 'Login using AE Connect'
parent: aeauth
route_name: ae.loginroute