function BreadcrumbPreprocess::preprocessBreadcrumb
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/
lib/ Drupal/ Core/ Breadcrumb/ BreadcrumbPreprocess.php, line 21
Class
- BreadcrumbPreprocess
- Breadcrumb theme preprocess.
Namespace
Drupal\Core\BreadcrumbCode
public function preprocessBreadcrumb(array &$variables) : void {
$variables['breadcrumb'] = [];
/** @var \Drupal\Core\Link $link */
foreach ($variables['links'] as $key => $link) {
$variables['breadcrumb'][$key] = [
'text' => $link->getText(),
'url' => $link->getUrl()
->toString(),
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.