-
Notifications
You must be signed in to change notification settings - Fork 0
/
galleryguide.install
166 lines (144 loc) · 3.52 KB
/
galleryguide.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
/**
* @file
* Install, update and uninstall functions for the standard installation profile.
*/
use Drupal\user\Entity\User;
use Drupal\user\RoleInterface;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function galleryguide_install() {
// Enable default modules.
galleryguide_modules();
// Allow visitor account creation with administrative approval.
$user_settings = \Drupal::configFactory()->getEditable('user.settings');
$user_settings->set('register', USER_REGISTER_VISITORS)
->save(TRUE);
galleryguide_shortcuts();
// Enable the admin theme.
\Drupal::configFactory()->getEditable('node.settings')
->set('use_admin_theme', TRUE)->save(TRUE);
// Enable default permissions for system roles.
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, galleryguide_permissions_anon());
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, galleryguide_permissions_auth());
}
/**
* Set up shortcuts.
*/
function galleryguide_shortcuts() {
// Assign user 1 the "administrator" role.
$user = User::load(1);
$user->roles[] = 'administrator';
$user->save();
// Populate the default shortcut set.
$shortcut = entity_create('shortcut', array(
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => -20,
'link' => array('uri' => 'internal:/node/add'),
));
$shortcut->save();
$shortcut = entity_create('shortcut', array(
'shortcut_set' => 'default',
'title' => t('All content'),
'weight' => -19,
'link' => array('uri' => 'internal:/admin/content'),
));
$shortcut->save();
}
/**
* Permissions for the anonymous user.
*
* @return array
* An array of permissions.
*/
function galleryguide_permissions_anon() {
return array(
'search content'
);
}
/**
* Permissions for the authenticated user.
*
* @return array
* An array of permissions.
*/
function galleryguide_permissions_auth() {
return array(
'access comments',
'post comments',
'skip comment approval',
'search content',
);
}
/**
* Enable default modules for the profile.
*
* Not using dependencies to allow uninstallation.
*/
function galleryguide_modules() {
$core_modules = array(
'node',
'history',
'block',
'breakpoint',
'ckeditor',
'color',
'config',
'comment',
'contextual',
'contact',
'menu_link_content',
'datetime',
'block_content',
'quickedit',
'editor',
'help',
'image',
'menu_ui',
'options',
'path',
'page_cache',
'dynamic_page_cache',
'taxonomy',
'dblog',
'search',
'shortcut',
'toolbar',
'field_ui',
'file',
'rdf',
'search',
'views',
'views_ui',
'tour',
'text',
'automated_cron',
);
$contrib_modules = array(
'address',
'adsense',
'composer_manager',
'geolocation',
'menu_trail_by_path',
'office_hours',
'prepopulate',
);
$custom_modules = array(
// 'gallery_migrations',
/*
exception 'Drupal\Core\Config\UnmetDependenciesException' with message [error]
'Configuration objects (migrate.migration.d6_imagecache_presets,
migrate.migration.d6_url_alias, migrate.migration.update_settings,
migrate.migration.user_picture_field) provided by gallery_migrations have
unmet dependencies' in
*/
);
$module_list = array_merge($core_modules, $contrib_modules, $custom_modules);
return \Drupal::service('module_installer')->install($module_list, TRUE);
}