-
Notifications
You must be signed in to change notification settings - Fork 1
/
localgov_geo.module
103 lines (90 loc) · 2.96 KB
/
localgov_geo.module
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* @file
* Provides a geo entity type.
*/
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
/**
* Implements hook_localgov_roles_default().
*/
function localgov_geo_localgov_roles_default() {
return [
// @codingStandardsIgnoreLine
\Drupal\localgov_roles\RolesHelper::EDITOR_ROLE => [
'access geo overview',
'create geo',
'delete geo',
'edit geo',
'access geo_entity_library entity browser pages',
],
// @codingStandardsIgnoreLine
\Drupal\localgov_roles\RolesHelper::AUTHOR_ROLE => [
'create geo',
'access geo_entity_library entity browser pages',
],
// @codingStandardsIgnoreLine
\Drupal\localgov_roles\RolesHelper::CONTRIBUTOR_ROLE => [
'create geo',
'access geo_entity_library entity browser pages',
],
];
}
/**
* Implements hook_menu_local_actions_alter().
*/
function localgov_geo_menu_local_actions_alter(&$local_actions) {
// Rename 'Add geo' to 'Add location'.
if (isset($local_actions['geo_entity.add_page'])) {
$local_actions['geo_entity.add_page']['title'] = t('Add location');
}
}
/**
* Implements hook_menu_local_tasks_alter().
*/
function localgov_geo_menu_local_tasks_alter(&$data, $route_name, RefinableCacheableDependencyInterface &$cacheability) {
// Rename 'Geo' tab to 'Locations' and increase its weight.
if (isset($data['tabs'][0]['entity.geo_entity.collection'])) {
$data['tabs'][0]['entity.geo_entity.collection']['#link']['title'] = t('Locations');
$data['tabs'][0]['entity.geo_entity.collection']['#weight'] = 50;
}
}
/**
* Implements hook_preprocess_HOOK() for breadcrumb.
*/
function localgov_geo_preprocess_breadcrumb(&$variables) {
// Change breadcrumb items from 'Geos' to 'Locations'.
$route_name = \Drupal::routeMatch()->getRouteName();
if ($route_name === 'entity.geo_entity.add_page') {
$variables['breadcrumb'][3]['text'] = t('Locations');
}
elseif ($route_name === 'entity.geo_entity.add_form') {
$variables['breadcrumb'][3]['text'] = t('Locations');
$variables['breadcrumb'][4]['text'] = t('Add location');
}
}
/**
* Implements hook_preprocess_HOOK() for html.
*/
function localgov_geo_preprocess_html(&$variables) {
// Change HTML title tag from 'Geos' to 'Locations'.
$route_name = \Drupal::routeMatch()->getRouteName();
if ($route_name === 'entity.geo_entity.collection') {
$variables['head_title']['title'] = t('Locations');
}
elseif ($route_name === 'entity.geo_entity.add_page') {
$variables['head_title']['title'] = t('Add location');
}
}
/**
* Implements hook_preprocess_HOOK() for page_title.
*/
function localgov_geo_preprocess_page_title(&$variables) {
// Change page title tag from 'Geos' to 'Locations'.
$route_name = \Drupal::routeMatch()->getRouteName();
if ($route_name === 'entity.geo_entity.collection') {
$variables['title'] = t('Locations');
}
elseif ($route_name === 'entity.geo_entity.add_page') {
$variables['title'] = t('Add location');
}
}