I need help to get all MenuLinkContent children from a specific MenuLinkContent and can't find a solution. I tried several different ways, but no success at all.
Here goes my code:
//get all MenuLinkContent published with name 'myname'
$main_menu = \Drupal::entityTypeManager()->getStorage('menu_link_content')
->loadByProperties(['menu_name' => 'myname' , 'enabled' => 1]);
foreach ($main_menu as $menu) {
//could not find a better solution, so i have to check if parent is empty.
if ($menu->getParentId()=='') {
//here i'm triyng to get all children,
$child_menu = \Drupal::entityTypeManager()->getStorage('menu_link_content')
->loadByProperties(['menu_name' => 'myname', 'parent' => $menu ]);
As you can see the property 'parent' do not fit with '$menu'. I tried several different properties from '$menu' and no one seems to match my query.
If more information is needed, just ask and i will post here. Other ways to achieve this iteration are welcome too.
Thanks in advance.