-
Notifications
You must be signed in to change notification settings - Fork 0
/
localgov_tasty_backend.install
52 lines (44 loc) · 1.67 KB
/
localgov_tasty_backend.install
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
<?php
/**
* @file
* Install, update and uninstall hooks for the Localgov tasty backend module.
*/
use Drupal\user\Entity\Role;
/**
* Implements hook_install().
*/
function localgov_tasty_backend_install($is_syncing) {
// Don't do anything on config sync operations.
if ($is_syncing) {
return;
}
// If admin theme is gin, also install tasty_backend_gin.
$admin_theme = \Drupal::config('system.theme')->get('admin');
$admin_theme_name = \Drupal::service('theme_handler')->getName($admin_theme);
if ($admin_theme_name == 'Gin') {
\Drupal::service('module_installer')->install(['tasty_backend_gin'], TRUE);
\Drupal::configFactory()
->getEditable('gin.settings')
->set('classic_toolbar', 'classic')
->save();
}
// Rename the manage menu to administration.
\Drupal::configFactory()
->getEditable('toolbar_menu.toolbar_menu_element.tb_manage')
->set('label', 'Manage website')
->save();
// Delete tasty backend user_admin role in favour of localgov_user_manager.
$tb_manage_users = \Drupal::configFactory()
->getEditable('views.view.tb_manage_users');
$dependencies = $tb_manage_users->get('dependencies.config');
$dependencies = array_filter($dependencies, function ($item) {
return $item != 'user.role.user_admin' ? $item : NULL;
});
$tb_manage_users->set('dependencies.config', $dependencies);
$tb_manage_users->clear('display.default.filters.roles_target_id.value.user_admin');
$tb_manage_users->clear('display.default.filters.roles_target_id.expose.remember_roles.user_admin');
$tb_manage_users->save();
Role::load('user_admin')?->delete();
// Flush all caches to refresh menus.
drupal_flush_all_caches();
}