function menu_ui_system_breadcrumb_alter

Same name and namespace in other branches
  1. 9 core/modules/menu_ui/menu_ui.module \menu_ui_system_breadcrumb_alter()
  2. 8.9.x core/modules/menu_ui/menu_ui.module \menu_ui_system_breadcrumb_alter()
  3. 10 core/modules/menu_ui/menu_ui.module \menu_ui_system_breadcrumb_alter()

Implements hook_system_breadcrumb_alter().

File

core/modules/menu_ui/menu_ui.module, line 449

Code

function menu_ui_system_breadcrumb_alter(Breadcrumb $breadcrumb, RouteMatchInterface $route_match, array $context) {
    // Custom breadcrumb behavior for editing menu links, we append a link to
    // the menu in which the link is found.
    if ($route_match->getRouteName() == 'menu_ui.link_edit' && ($menu_link = $route_match->getParameter('menu_link_plugin'))) {
        if ($menu_link instanceof MenuLinkInterface) {
            // Add a link to the menu admin screen.
            $menu = Menu::load($menu_link->getMenuName());
            $breadcrumb->addLink(Link::createFromRoute($menu->label(), 'entity.menu.edit_form', [
                'menu' => $menu->id(),
            ]));
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.