standard.install 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the standard installation profile.
  5. */
  6. use Drupal\user\Entity\User;
  7. use Drupal\shortcut\Entity\Shortcut;
  8. /**
  9. * Implements hook_install().
  10. *
  11. * Perform actions to set up the site for this profile.
  12. *
  13. * @see system_install()
  14. */
  15. function standard_install() {
  16. // Assign user 1 the "administrator" role.
  17. $user = User::load(1);
  18. $user->roles[] = 'administrator';
  19. $user->save();
  20. // We install some menu links, so we have to rebuild the router, to ensure the
  21. // menu links are valid.
  22. \Drupal::service('router.builder')->rebuildIfNeeded();
  23. // Populate the default shortcut set.
  24. $shortcut = Shortcut::create([
  25. 'shortcut_set' => 'default',
  26. 'title' => t('Add content'),
  27. 'weight' => -20,
  28. 'link' => ['uri' => 'internal:/node/add'],
  29. ]);
  30. $shortcut->save();
  31. $shortcut = Shortcut::create([
  32. 'shortcut_set' => 'default',
  33. 'title' => t('All content'),
  34. 'weight' => -19,
  35. 'link' => ['uri' => 'internal:/admin/content'],
  36. ]);
  37. $shortcut->save();
  38. }