- Issue created by @welly
- Status changed to Closed: works as designed
over 1 year ago 4:43pm 12 September 2023 - 🇬🇧United Kingdom welly
It's just occurred to me why this isn't working. So I'll close this issue.
- Status changed to Active
over 1 year ago 9:45am 19 September 2023 - 🇬🇧United Kingdom welly
Reopening this as I'm running into a new similar/related issue. When programmatically creating menu links that will live in a different menu entirely, I keep finding that menu_tree gets updated with group_menu_link_content-1 rather than the menu name that I've specified.
I've been creating my menu link as follows. The node is a node that belongs to a group so wonder if something is post processing the menu link creation to assign the link to a different menu? Oddly, if I look at menu_link_content, I can see the correct group has been stored in menu_name, it's just in menu_tree where it differs.
$menu_link = \Drupal::entityTypeManager() ->getStorage('menu_link_content') ->create([ 'title' => $definition['title'], 'description' => $definition['description'], 'link' => [ 'uri' => 'entity:node/' . $definition['route_parameters']['node'], ], 'menu_name' => $menu_name, 'weight' => $definition['weight'], 'enabled' => boolval($definition['enabled']) ? TRUE : FALSE, 'expanded' => boolval($definition['expanded']) ? TRUE : FALSE, 'parent' => $definition['id'] !== $parent_menu_link['id'] ? $parent_menu_link['id'] : NULL, ]); $menu_link->save();
- Status changed to Closed: works as designed
over 1 year ago 10:24am 19 September 2023 - 🇬🇧United Kingdom welly
Ok, closing this (again) :) It looks like it's something in MenuTreeStorage which is causing this issue and I think I've found a work around.