forked from digitalutsc/islandora_breadcrumbs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathislandora_breadcrumbs.module
More file actions
47 lines (42 loc) · 1.09 KB
/
Copy pathislandora_breadcrumbs.module
File metadata and controls
47 lines (42 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* @file
* Primary module hooks for Islandora Breadcrumbs module.
*/
use Drupal\node\NodeInterface;
/**
* Implements hook_theme().
*/
function islandora_breadcrumbs_theme($existing, $type, $theme, $path) {
return [
'islandora_breadcrumb' => [
'variables' => [
'links' => [],
],
],
];
}
/**
* Prepares variables for breadcrumb templates.
*
* Adapted from theme.inc/template_preprocess_breadcrumb.
*
* @param array $variables
* An associative array containing:
* - links: A list of \Drupal\Core\Link objects which should be rendered.
*/
function islandora_breadcrumbs_preprocess_islandora_breadcrumb(array &$variables) {
$variables['breadcrumb'] = [];
$route_name = \Drupal::routeMatch()->getRouteName();
if (strpos($route_name, "view.group") === false) {
/** @var \Drupal\Core\Link $link */
foreach ($variables['links'] as $key => $links) {
foreach ($links as $link) {
$variables['breadcrumb'][$key][] = [
'text' => $link->getText(),
'url' => $link->getUrl()->toString(),
];
}
}
}
}