diff --git a/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php b/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php index 77501eb..ec587a3 100644 --- a/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php +++ b/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php @@ -69,6 +69,7 @@ public function addBuilder(BreadcrumbBuilderInterface $builder, $priority) { */ public function build(array $attributes) { $breadcrumb = array(); + $context = array('builder' => NULL); $successful_builder = NULL; // Call the build method of registered breadcrumb builders, // until one of them returns an array. @@ -81,7 +82,7 @@ public function build(array $attributes) { elseif (is_array($build)) { // The builder returned an array of breadcrumb links. $breadcrumb = $build; - $successful_builder = $builder; + $context['builder'] = $builder; break; } else { @@ -89,7 +90,7 @@ public function build(array $attributes) { } } // Allow modules to alter the breadcrumb. - $this->moduleHandler->alter('system_breadcrumb', $breadcrumb, $attributes, $successful_builder); + $this->moduleHandler->alter('system_breadcrumb', $breadcrumb, $attributes, $context); // Fall back to an empty breadcrumb. return $breadcrumb; } diff --git a/core/modules/menu_link/menu_link.module b/core/modules/menu_link/menu_link.module index 105e502..c37d353 100644 --- a/core/modules/menu_link/menu_link.module +++ b/core/modules/menu_link/menu_link.module @@ -195,3 +195,20 @@ function menu_link_maintain($module, $op, $link_path, $link_title = NULL) { break; } } + +/** + * Implements hook_system_breadcrumb_alter(). + */ +function menu_link_system_breadcrumb_alter(array &$breadcrumb, array $attributes, array $context) { + + // Custom breadcrumb behaviour for editing menu links, we append a link to + // the menu in which the link is found. + if (!empty($attributes['_route']) && $attributes['_route'] == 'menu_link_edit' && !empty($attributes['menu_link'])) { + $menu_link = $attributes['menu_link']; + if (($menu_link instanceof MenuLink) && !$menu_link->isNew()) { + // Add a link to the menu admin screen. + $menu = entity_load('menu', $menu_link->menu_name); + $breadcrumb[] = Drupal::l($menu->label(), 'menu_menu_edit', array('menu' => $menu->id)); + } + } +} \ No newline at end of file diff --git a/core/modules/system/lib/Drupal/system/PathBasedBreadcrumbBuilder.php b/core/modules/system/lib/Drupal/system/PathBasedBreadcrumbBuilder.php index ab62350..d905b97 100644 --- a/core/modules/system/lib/Drupal/system/PathBasedBreadcrumbBuilder.php +++ b/core/modules/system/lib/Drupal/system/PathBasedBreadcrumbBuilder.php @@ -106,17 +106,6 @@ public function __construct(Request $request, EntityManager $entity_manager, Acc public function build(array $attributes) { $links = array(); - // Custom breadcrumb behaviour for editing menu links, we append a link to - // the menu in which the link is found. - if (!empty($attributes['_route']) && $attributes['_route'] == 'menu_link_edit' && !empty($attributes['menu_link'])) { - $menu_link = $attributes['menu_link']; - if (!$menu_link->isNew()) { - // Add a link to the menu admin screen. - $menu = $this->menuStorage->load($menu_link->menu_name); - $links[] = l($menu->label(), 'admin/structure/menu/manage/' . $menu_link->menu_name); - } - } - // General path-based breadcrumbs. Use the original, aliased path. $path = trim($this->request->getPathInfo(), '/'); $path_elements = explode('/', $path); diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 1671c7f..7a1c87b 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -1357,11 +1357,13 @@ function hook_module_implements_alter(&$implementations, $hook) { * Array of breadcrumb links. * @param array $attributes * Attributes representing the current page. - * @param \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface $builder - * The builder instance that constructed this breadcrumb, or NULL if no - * builder acted based on the current attributes. + * @param array $context + * May include the following keys: + * - builder: the instance of \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface + * that constructed this breadcrumb, or NULL if no builder acted based on + * the current attributes. */ -function hook_system_breadcrumb_alter(array &$breadcrumb, array $attributes, $builder = NULL) { +function hook_system_breadcrumb_alter(array &$breadcrumb, array $attributes, array $context) { // Add an item to the end of the breadcrumb. }