Let say I have a menu item with these attributes
'title' => 'Menu Title',
'link' => ['uri' => 'internal:/taxonomy/term/1217'],
'menu_name' => 'my-menu',
'expanded' => TRUE,
I can find all the menus by their title, e.g.,
$menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')
->loadByProperties(['title' => 'Menu Title']);
if ($menu_link = reset($menu_links)) {
// Get the pid of the first menu
$menu_pid = $menu_link->getPluginId();
}
Then I tried to retrieve menu by the link property, and I couldn't. I tried:
$menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')
->loadByProperties(['link' => array('uri' => 'internal:/taxonomy/term/1217')]);
$menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')
->loadByProperties(['link' => ['uri' => 'internal:/taxonomy/term/1217']]);
$menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')
->loadByProperties(['uri' => 'internal:/taxonomy/term/1217']);
None of them worked.