shortcut.install 1.92 KB
Newer Older
1 2 3 4 5 6 7 8
<?php

/**
 * @file
 * Install, update and uninstall functions for the shortcut module.
 */

/**
9
 * Implements hook_schema().
10 11 12 13 14 15 16 17 18 19 20 21 22
 */
function shortcut_schema() {
  $schema['shortcut_set_users'] = array(
    'description' => 'Maps users to shortcut sets.',
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {users}.uid for this set.',
      ),
      'set_name' => array(
23
        'type' => 'varchar_ascii',
24 25 26 27 28 29 30 31 32 33 34
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => "The {shortcut_set}.set_name that will be displayed for this user.",
      ),
    ),
    'primary key' => array('uid'),
    'indexes' => array(
      'set_name' => array('set_name'),
    ),
    'foreign keys' => array(
35 36 37 38 39 40 41 42
      'set_user' => array(
        'table' => 'users',
        'columns' => array('uid' => 'uid'),
      ),
      'set_name' => array(
        'table' => 'shortcut_set',
        'columns' => array('set_name' => 'set_name'),
      ),
43 44 45 46 47
    ),
  );

  return $schema;
}
48 49 50 51 52 53 54 55

/**
 * Implements hook_install().
 */
function shortcut_install() {
  // Theme settings are not configuration entities and cannot depend on modules
  // so to set a module-specific setting, we need to set it with logic.
  if (\Drupal::service('theme_handler')->themeExists('seven')) {
56
    \Drupal::configFactory()->getEditable('seven.settings')->set('third_party_settings.shortcut.module_link', TRUE)->save(TRUE);
57 58 59 60 61 62 63 64 65 66
  }
}

/**
 * Implements hook_uninstall().
 */
function shortcut_uninstall() {
  // Theme settings are not configuration entities and cannot depend on modules
  // so to unset a module-specific setting, we need to unset it with logic.
  if (\Drupal::service('theme_handler')->themeExists('seven')) {
67
    \Drupal::configFactory()->getEditable('seven.settings')->clear('third_party_settings.shortcut.module_link')->save(TRUE);
68 69
  }
}