You are here

function demo_umami_install in Drupal 10

Same name and namespace in other branches
  1. 8 core/profiles/demo_umami/demo_umami.install \demo_umami_install()
  2. 9 core/profiles/demo_umami/demo_umami.install \demo_umami_install()

Implements hook_install().

Perform actions to set up the site for this profile.

See also

system_install()

File

core/profiles/demo_umami/demo_umami.install, line 36
Install, update and uninstall functions for the demo_umami installation profile.

Code

function demo_umami_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([
    'demo_umami_content',
  ], TRUE);
}