shortcut.install 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the shortcut module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function shortcut_schema() {
  10. $schema['shortcut_set_users'] = [
  11. 'description' => 'Maps users to shortcut sets.',
  12. 'fields' => [
  13. 'uid' => [
  14. 'type' => 'int',
  15. 'unsigned' => TRUE,
  16. 'not null' => TRUE,
  17. 'default' => 0,
  18. 'description' => 'The {users}.uid for this set.',
  19. ],
  20. 'set_name' => [
  21. 'type' => 'varchar_ascii',
  22. 'length' => 32,
  23. 'not null' => TRUE,
  24. 'default' => '',
  25. 'description' => "The {shortcut_set}.set_name that will be displayed for this user.",
  26. ],
  27. ],
  28. 'primary key' => ['uid'],
  29. 'indexes' => [
  30. 'set_name' => ['set_name'],
  31. ],
  32. 'foreign keys' => [
  33. 'set_user' => [
  34. 'table' => 'users',
  35. 'columns' => ['uid' => 'uid'],
  36. ],
  37. 'set_name' => [
  38. 'table' => 'shortcut_set',
  39. 'columns' => ['set_name' => 'set_name'],
  40. ],
  41. ],
  42. ];
  43. return $schema;
  44. }
  45. /**
  46. * Implements hook_install().
  47. */
  48. function shortcut_install() {
  49. // Theme settings are not configuration entities and cannot depend on modules
  50. // so to set a module-specific setting, we need to set it with logic.
  51. if (\Drupal::service('theme_handler')->themeExists('seven')) {
  52. \Drupal::configFactory()->getEditable('seven.settings')->set('third_party_settings.shortcut.module_link', TRUE)->save(TRUE);
  53. }
  54. }
  55. /**
  56. * Implements hook_uninstall().
  57. */
  58. function shortcut_uninstall() {
  59. // Theme settings are not configuration entities and cannot depend on modules
  60. // so to unset a module-specific setting, we need to unset it with logic.
  61. if (\Drupal::service('theme_handler')->themeExists('seven')) {
  62. \Drupal::configFactory()->getEditable('seven.settings')->clear('third_party_settings.shortcut')->save(TRUE);
  63. }
  64. }