When I have a node on the main menu, I can find its Menu Settings with an entityQuery
on the content entity for its menu link, for example:
$system_uri = "entity:node/42";
$query = \Drupal::entityQuery('menu_link_content')
->condition('menu_name', 'main')
->condition('link.uri', $system_uri);
$result = $query->execute();
$menu_link_id = reset($result);
$menu_link = MenuLinkContent::load($menu_link_id);
... then get the Menu Link Title and Parent Item with these methods from the relevant class:
$menu_link_title = $menu_link->getTitle();
$menu_link_parent = $menu_link->getParentId();
I can't do the same thing with a view. Even an entityQuery
of all menu_link_content
entities on the main
menu doesn't return views that are on that menu: only nodes and taxonomy term entities.
And I can't see these settings in what I believed would be the corresponding configuration entity for a View, for example:
$view_id = 'frontpage';
$query = \Drupal::entityQuery('view')
->condition('id', $view_id);
$result = $query->execute();
$view_id = reset($result);
$view = \Drupal::service('entity.manager')->getStorage('view')->load($view_id);
The resulting Drupal\views\Entity\View
object doesn't look like it has any properties or methods to access the configuration data in the Views UI, specifically the Menu Link Title and Parent under Page Settings. What is the correct way to extract this information?