You are here

taxonomy_menu.install in Taxonomy menu 8

Install and uninstall all required databases. Also do incremental database updates.

File

taxonomy_menu.install
View source
<?php

/**
 * @file
 * Install and uninstall all required databases. Also do incremental database updates.
 */
use Drupal\Core\Language\Language;

/**
 * Implements hook_uninstall().
 */
function taxonomy_menu_uninstall() {

  // Remove menu items.
  db_delete('menu_links')
    ->condition('module', 'taxonomy_menu')
    ->execute();

  // Rebuild the menus.
  \Drupal::state()
    ->set('menu_rebuild_needed', TRUE);
}

/**
 * Implements hook_schema().
 */
function taxonomy_menu_schema() {
  $schema['taxonomy_menu'] = array(
    'description' => 'Links a taxonomy term to a menu item.',
    'fields' => array(
      'mlid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The taxonomy terms {menu_link}.mlid.',
      ),
      'tid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Tid that is linked to the mlid.',
      ),
      'vid' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Vid for the tid.',
      ),
      'language' => array(
        'description' => 'Language code, e.g. ’de’ or ’en-US’.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => Language::LANGCODE_NOT_SPECIFIED,
      ),
    ),
    'primary key' => array(
      'mlid',
      'tid',
      'language',
    ),
    'indexes' => array(
      'vid' => array(
        'vid',
      ),
    ),
  );
  return $schema;
}

Functions