function template_preprocess_breadcrumb in Drupal 8
Same name and namespace in other branches
- 9 core/includes/theme.inc \template_preprocess_breadcrumb()
Prepares variables for breadcrumb templates.
Default template: breadcrumb.html.twig.
Parameters
array $variables: An associative array containing:
- links: A list of \Drupal\Core\Link objects which should be rendered.
File
- core/
includes/ theme.inc, line 1723 - The theme system, which controls the output of Drupal.
Code
function template_preprocess_breadcrumb(&$variables) {
$variables['breadcrumb'] = [];
/** @var \Drupal\Core\Link $link */
foreach ($variables['links'] as $key => $link) {
$variables['breadcrumb'][$key] = [
'text' => $link
->getText(),
'url' => $link
->getUrl()
->toString(),
];
}
}