-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbt_core.module
74 lines (64 loc) · 1.87 KB
/
bt_core.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
<?php
/**
* @file
* Drupal module file.
*/
use Drupal\Core\Render\Element;
/**
* Implements hook_theme().
*/
function bt_core_theme() {
return [
'multifield' => [
'render element' => 'elements',
],
];
}
/**
* Prepares variables for multifield templates.
*
* Default template: multifield.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the multifield
* information and any
* fields attached to the entity.
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_multifield(array &$variables) {
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
/**
* Implements hook_menu_links_discovered_alter().
*/
function bt_core_menu_links_discovered_alter(&$links) {
unset($links['system.admin_content']);
unset($links['comment.admin']);
}
/**
* Implements hook_menu_local_tasks_alter().
*/
function bt_core_menu_local_tasks_alter(&$data, $route_name) {
$routes = [
'entity.user.canonical',
'entity.user.edit_form',
'entity.user.contact_form',
];
if (in_array($route_name, $routes)) {
$uid = \Drupal::request()->attributes->get('_raw_variables')->get('user');
$cuid = \Drupal::service('current_user')->id();
$data['tabs'][0]['entity.user.edit_form']['#weight'] = 5;
$data['tabs'][0]['entity.user.contact_form']['#weight'] = 4;
if ($cuid == $uid) {
$data['tabs'][0]['entity.user.canonical']['#link']['title'] = t('My account');
$data['tabs'][0]['entity.user.edit_form']['#link']['title'] = t('Edit my account');
}
else {
$data['tabs'][0]['entity.user.canonical']['#link']['title'] = t('User account');
$data['tabs'][0]['entity.user.edit_form']['#link']['title'] = t('Edit user account');
}
}
}