menu_ui_system_breadcrumb_alter

menu_ui_system_breadcrumb_alter(Breadcrumb &$breadcrumb, RouteMatchInterface $route_match, array $context)

Implements hook_system_breadcrumb_alter().

File

core/modules/menu_ui/menu_ui.module, line 504
Allows administrators to customize the site's navigation menus.

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()]));
    }
  }
}
doc_Drupal
2016-10-29 09:27:53
Comments
Leave a Comment

Please login to continue.