forked from drupalwxt/wxt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wxt.install
98 lines (89 loc) · 2.31 KB
/
wxt.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
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
<?php
/**
* @file
* Install and uninstall functions for the WxT installation profile.
*/
use Drupal\menu_link_content\Entity\MenuLinkContent;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function wxt_install() {
_wxt_setup_themes();
_wxt_setup_branding();
_wxt_setup_menus();
_wxt_setup_base_configurations();
}
/**
* Setup base site configurations.
*/
function _wxt_setup_base_configurations() {
// Ensure the translation fields are created in the database.
\Drupal::service('entity.definition_update_manager')->applyUpdates();
}
/**
* Set up the default branding.
*/
function _wxt_setup_branding() {
// Set the path to the logo, favicon and README file based on install
// directory.
$wxt_path = drupal_get_path('profile', 'wxt');
\Drupal::configFactory()
->getEditable('system.theme.global')
->set('logo', [
'path' => $wxt_path . '/wxt.svg',
'url' => '',
'use_default' => FALSE,
])
->set('favicon', [
'mimetype' => 'image/vnd.microsoft.icon',
'path' => $wxt_path . '/favicon.ico',
'url' => '',
'use_default' => FALSE,
])
->save(TRUE);
}
/**
* Set up the default menu override(s).
*/
function _wxt_setup_menus() {
/** @var \Drupal\menu_link_content\MenuLinkContentInterface $user_account */
$parent_link = MenuLinkContent::create([
'menu_name' => 'account',
'link' => 'route:<nolink>',
'title' => 'User Account',
'expanded' => TRUE,
]);
$parent_link->save();
$menu_links = [
'user.page',
'user.logout',
];
foreach ($menu_links as $menu_link) {
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
$link = $menu_link_manager->getDefinition($menu_link);
$link['parent'] = $parent_link->getPluginId();
$menu_link_manager->updateDefinition($menu_link, $link);
$cache = \Drupal::cache('menu');
$cache->deleteAll();
}
}
/**
* Setup the themes.
*/
function _wxt_setup_themes() {
// Set the default and admin theme.
\Drupal::configFactory()
->getEditable('system.theme')
->set('default', 'wxt_bootstrap')
->set('admin', 'seven')
->save(TRUE);
// Enable the admin theme.
\Drupal::configFactory()
->getEditable('node.settings')
->set('use_admin_theme', TRUE)
->save(TRUE);
}