forked from govCMS/GovCMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
govcms.install
92 lines (82 loc) · 2.34 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
<?php
/**
* @file
* Install, update and uninstall functions for the GovCMS installation profile.
*/
use Drupal\shortcut\Entity\Shortcut;
use Drupal\menu_link_content\Entity\MenuLinkContent;
// GovCMS update hooks.
include_once __DIR__ . '/includes/govcms.update.inc';
/**
* Implements hook_install().
*
* Sets up the GovCMS profile during installation.
*
* @see system_install()
*/
function govcms_install() {
// Create default shortcut for adding content.
Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => 1,
'link' => ['uri' => 'internal:/node/add'],
])->save();
// Create footer menu links.
$footerMenuLinks = ['Accessibility', 'Copyright', 'Disclaimers', 'Privacy'];
foreach ($footerMenuLinks as $linkTitle) {
MenuLinkContent::create([
'title' => $linkTitle,
'link' => ['uri' => 'https://www.govcms.gov.au'],
'menu_name' => 'footer',
])->save();
}
// Create custom menu links.
$customMenuLinks = [
[
'title' => 'Our community',
'path' => '/our-community',
'menu_name' => 'govcms-community',
],
[
'title' => 'About GovCMS',
'path' => '/about',
'menu_name' => 'govcms-about',
],
];
foreach ($customMenuLinks as $customLink) {
MenuLinkContent::create([
'title' => $customLink['title'],
'link' => ['uri' => 'https://www.govcms.gov.au' . $customLink['path']],
'menu_name' => $customLink['menu_name'],
])->save();
}
// Skip further actions during config sync.
if (\Drupal::isConfigSyncing()) {
return;
}
// Set front page to "node".
$frontPagePath = '/node';
\Drupal::configFactory()
->getEditable('system.site')
->set('page.front', $frontPagePath)
->save(TRUE);
// Set paths for the logo, favicon, and README file based on install directory.
$govcmsPath = \Drupal::service('extension.list.profile')->getPath('govcms');
\Drupal::configFactory()
->getEditable('system.theme.global')
->set('logo', [
'path' => $govcmsPath . '/logo.svg',
'url' => '',
'use_default' => TRUE,
])
->set('favicon', [
'mimetype' => 'image/vnd.microsoft.icon',
'path' => $govcmsPath . '/favicon.ico',
'url' => '',
'use_default' => FALSE,
])
->save(TRUE);
// Grant default permissions.
govcms_default_permissions();
}