5 * Install, update and uninstall functions for the demo_umami installation profile.
8 use Drupal\user\Entity\User;
9 use Drupal\shortcut\Entity\Shortcut;
12 * Implements hook_requirements().
14 function demo_umami_requirements($phase) {
16 if ($phase == 'runtime') {
17 $profile = \Drupal::installProfile();
18 $info = system_get_info('module', $profile);
19 $requirements['experimental_profile_used'] = [
20 'title' => t('Experimental installation profile used'),
21 'value' => $info['name'],
22 'description' => t('Experimental profiles are provided for testing purposes only. Use at your own risk. To start building a new site, reinstall Drupal and choose a non-experimental profile.'),
23 'severity' => REQUIREMENT_WARNING,
30 * Implements hook_install().
32 * Perform actions to set up the site for this profile.
34 * @see system_install()
36 function demo_umami_install() {
37 // Assign user 1 the "administrator" role.
38 $user = User::load(1);
39 $user->roles[] = 'administrator';
42 // We install some menu links, so we have to rebuild the router, to ensure the
43 // menu links are valid.
44 \Drupal::service('router.builder')->rebuildIfNeeded();
46 // Populate the default shortcut set.
47 $shortcut = Shortcut::create([
48 'shortcut_set' => 'default',
49 'title' => t('Add content'),
51 'link' => ['uri' => 'internal:/node/add'],
55 $shortcut = Shortcut::create([
56 'shortcut_set' => 'default',
57 'title' => t('All content'),
59 'link' => ['uri' => 'internal:/admin/content'],
63 // Enable the demo content module. This can't be specified as a dependency
64 // in the demo_umami.info.yml file, as it requires configuration provided by
65 // the profile (fields etc.).
66 \Drupal::service('module_installer')->install(['demo_umami_content'], TRUE);