W3cubDocs

/Drupal 8

function hook_system_breadcrumb_alter

hook_system_breadcrumb_alter(\Drupal\Core\Breadcrumb\Breadcrumb &$breadcrumb, \Drupal\Core\Routing\RouteMatchInterface $route_match, array $context)

Perform alterations to the breadcrumb built by the BreadcrumbManager.

Parameters

\Drupal\Core\Breadcrumb\Breadcrumb $breadcrumb: A breadcrumb object returned by BreadcrumbBuilderInterface::build().

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.

array $context: May include the following key:

Related topics

Hooks
Define functions that alter the behavior of Drupal core.
Menu system
Define the navigation menus, local actions and tasks, and contextual links.

File

core/lib/Drupal/Core/Menu/menu.api.php, line 431
Hooks and documentation related to the menu system and links.

Code

function hook_system_breadcrumb_alter(\Drupal\Core\Breadcrumb\Breadcrumb &$breadcrumb, \Drupal\Core\Routing\RouteMatchInterface $route_match, array $context) {
  // Add an item to the end of the breadcrumb.
  $breadcrumb->addLink(\Drupal\Core\Link::createFromRoute(t('Text'), 'example_route_name'));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!menu.api.php/function/hook_system_breadcrumb_alter/8.1.x