-
Notifications
You must be signed in to change notification settings - Fork 1
/
coderiders.install
58 lines (49 loc) · 1.53 KB
/
coderiders.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
<?php
/**
* @file
* Install, update and uninstall functions for the demo_umami installation profile.
*/
use Drupal\user\Entity\User;
use Drupal\shortcut\Entity\Shortcut;
use Drupal\Core\Config\FileStorage;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function coderiders_install() {
// Assign user 1 the "administrator" role.
/** @var \Drupal\user\Entity\User $user */
$user = User::load(1);
$user->addRole('administrator');
$user->save();
// We install some menu links, so we have to rebuild the router, to ensure the
// menu links are valid.
\Drupal::service('router.builder')->rebuildIfNeeded();
// Populate the default shortcut set.
$shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => -20,
'link' => ['uri' => 'internal:/node/add'],
]);
$shortcut->save();
$shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('All content'),
'weight' => -19,
'link' => ['uri' => 'internal:/admin/content'],
]);
$shortcut->save();
// Enable the demo content module. This can't be specified as a dependency
// in the demo_umami.info.yml file, as it requires configuration provided by
// the profile (fields etc.).
\Drupal::service('module_installer')->install(['coderider_demo_content'], TRUE);
$config = \Drupal::configFactory();
// Set default home page.
$config->getEditable('system.site')
->set('page.front', '/node/1')
->save(TRUE);
}