forked from marvil07/isovera-profile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
isovera.install
45 lines (36 loc) · 1.55 KB
/
isovera.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
<?php
/**
* @file
* The installation implementation for isovera 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 isovera_install() {
// Assign user 1 the "administrator" role.
$user = User::load(1);
$user->roles[] = 'administrator';
$user->save();
// Allow only administrators to create user account.
$user_settings = \Drupal::configFactory()->getEditable('user.settings');
$user_settings->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save(TRUE);
// System default permissions for system roles.
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access comments'));
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array());
// Search default permissions for system roles.
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('search content'));
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('search content'));
// Contact default permissions for the system roles.
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access site-wide contact form'));
// Set front page to "node".
\Drupal::configFactory()->getEditable('system.site')->set('page.front', '/node')->save(TRUE);
// Enable the admin theme.
\Drupal::configFactory()->getEditable('node.settings')->set('use_admin_theme', TRUE)->save(TRUE);
}