forked from govCMS/GovCMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgovcms.install
132 lines (114 loc) · 3.11 KB
/
govcms.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
* @file
* Install, update and uninstall functions for the GovCMS installation profile.
*/
use Drupal\node\Entity\Node;
use Drupal\shortcut\Entity\Shortcut;
use Drupal\menu_link_content\Entity\MenuLinkContent;
/**
* Define a default theme constant.
*/
define('GOVCMS_DEFAULT_THEME', 'govcms_bartik');
/**
* Define the admin theme.
*/
define('GOVCMS_DEFAULT_ADMIN_THEME', 'claro');
/**
* Implements hook_install().
*
* Perform actions to set up the site for GovCMS Profile.
*
* @see system_install()
*/
function govcms_install() {
// Restrict user registration to admin role creation.
\Drupal::configFactory()
->getEditable('user.settings')
->set('register', \Drupal\user\UserInterface::REGISTER_ADMINISTRATORS_ONLY)
->save(TRUE);
// Populate the default shortcut set.
Shortcut::create(
[
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => 1,
'link' => ['uri' => 'internal:/node/add'],
]
)->save();
MenuLinkContent::create(
[
'title' => 'Accessibility',
'link' => ['uri' => 'https://www.govcms.gov.au'],
'menu_name' => 'footer',
]
)->save();
MenuLinkContent::create(
[
'title' => 'Copyright',
'link' => ['uri' => 'https://www.govcms.gov.au'],
'menu_name' => 'footer',
]
)->save();
MenuLinkContent::create(
[
'title' => 'Disclaimers',
'link' => ['uri' => 'https://www.govcms.gov.au'],
'menu_name' => 'footer',
]
)->save();
MenuLinkContent::create(
[
'title' => 'Privacy',
'link' => ['uri' => 'https://www.govcms.gov.au'],
'menu_name' => 'footer',
]
)->save();
MenuLinkContent::create([
'title' => 'Our community',
'link' => ['uri' => 'https://www.govcms.gov.au/our-community'],
'menu_name' => 'govcms-community',
])->save();
MenuLinkContent::create([
'title' => 'About GovCMS',
'link' => ['uri' => 'https://www.govcms.gov.au/about'],
'menu_name' => 'govcms-about',
])->save();
// Don't do anything else during config sync.
if (\Drupal::isConfigSyncing()) {
return;
}
// Set front page to "node".
\Drupal::configFactory()
->getEditable('system.site')
->set('page.front', '/node')
->save(TRUE);
// Set the default and admin theme.
\Drupal::configFactory()
->getEditable('system.theme')
->set('default', GOVCMS_DEFAULT_THEME)
->set('admin', GOVCMS_DEFAULT_ADMIN_THEME)
->save(TRUE);
// Enable the admin theme.
\Drupal::configFactory()
->getEditable('node.settings')
->set('use_admin_theme', TRUE)
->save(TRUE);
// Set the path to the logo, favicon and README file based on install directory.
$govcms_path = drupal_get_path('profile', 'govcms');
\Drupal::configFactory()
->getEditable('system.theme.global')
->set('logo', [
'path' => $govcms_path . '/logo.svg',
'url' => '',
'use_default' => TRUE,
])
->set('favicon', [
'mimetype' => 'image/vnd.microsoft.icon',
'path' => $govcms_path . '/favicon.ico',
'url' => '',
'use_default' => FALSE,
])
->save(TRUE);
drupal_flush_all_caches();
}