This repository has been archived by the owner on Nov 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
/
lightning.profile
103 lines (91 loc) · 2.71 KB
/
lightning.profile
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
<?php
/**
* @file
* The Lightning profile.
*/
use Drupal\user\RoleInterface;
/**
* Implements hook_install_tasks().
*/
function lightning_install_tasks(array &$install_state) {
$tasks = [];
// All of these tasks modify configuration, so don't do any of them if
// we're installing from existing config.
if (empty($install_state['config_install_path'])) {
$tasks['lightning_set_front_page'] = [];
$tasks['lightning_grant_shortcut_access'] = [];
$tasks['lightning_set_default_theme'] = [];
$tasks['lightning_set_logo'] = [];
$tasks['lightning_alter_frontpage_view'] = [];
}
return $tasks;
}
/**
* Sets the front page path to /node.
*/
function lightning_set_front_page() {
if (Drupal::moduleHandler()->moduleExists('node')) {
Drupal::configFactory()
->getEditable('system.site')
->set('page.front', '/node')
->save(TRUE);
}
}
/**
* Allows authenticated users to use shortcuts.
*/
function lightning_grant_shortcut_access() {
if (Drupal::moduleHandler()->moduleExists('shortcut')) {
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access shortcuts']);
}
}
/**
* Sets the default and administration themes.
*/
function lightning_set_default_theme() {
Drupal::configFactory()
->getEditable('system.theme')
->set('default', 'bartik')
->set('admin', 'claro')
->save(TRUE);
// Use the admin theme for creating content.
if (Drupal::moduleHandler()->moduleExists('node')) {
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.
*/
function lightning_set_logo() {
$lightning_path = drupal_get_path('profile', 'lightning');
Drupal::configFactory()
->getEditable('system.theme.global')
->set('logo', [
'path' => $lightning_path . '/lightning.png',
'url' => '',
'use_default' => FALSE,
])
->set('favicon', [
'mimetype' => 'image/vnd.microsoft.icon',
'path' => $lightning_path . '/favicon.ico',
'url' => '',
'use_default' => FALSE,
])
->save(TRUE);
}
/**
* Alters the frontpage view, if it exists.
*/
function lightning_alter_frontpage_view() {
$front_page = Drupal::configFactory()->getEditable('views.view.frontpage');
if (!$front_page->isNew()) {
$section = 'display.default.display_options.empty.area_text_custom';
$front_page
->set("$section.tokenize", TRUE)
->set("$section.content", '<p>Welcome to [site:name]. No front page content has been created yet.</p><p>Would you like to <a href="/' . drupal_get_path('profile', 'lightning') . '/README.md">view the README</a>?</p>')
->save(TRUE);
}
}