I’m struggling to figure out relationship between MenuLink and MenuLinkContent.
I’m creating new menu item like:
$menuItem = MenuLinkContent::create($params);
And that works well. Now if I need one of those object I want to get it’s "siblings" – other object that share same parent. I have some weird structure:
$this->menuLinkManager = Drupal::service('plugin.manager.menu.link'); $parentId = $menuItem->getParentId(); $parent = $this->menuLinkManager->createInstance($this->menuLinkManager->getDefinition($parentId)['id']);
And here I’m getting it’s parent, but it’s not MenuLinkContent object any more but instance of MenuLinkInterface. It has some fields as MenuLinkContent, but not all. I.e. I don’t know how to get link path and similar.
There I can go further:
$siblings = $this->menuLinkManager->getChildIds($parent->getPluginId());
But main question is how to get MenuLinkContent when I have that MenuLinkInterface object?
Sub-question – why oh why is needed this parallel menu system and parallel menu classes?