book.install

Same filename in other branches
  1. 7.x modules/book/book.install
  2. 9 core/modules/book/book.install
  3. 10 core/modules/book/book.install
  4. 11.x core/modules/book/book.install

Install, update and uninstall functions for the book module.

File

core/modules/book/book.install

View source
<?php


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

/**
 * Implements hook_uninstall().
 */
function book_uninstall() {
    // Clear book data out of the cache.
    \Drupal::cache('data')->deleteAll();
}

/**
 * Implements hook_schema().
 */
function book_schema() {
    $schema['book'] = [
        'description' => 'Stores book outline information. Uniquely defines the location of each node in the book outline',
        'fields' => [
            'nid' => [
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
                'description' => "The book page's {node}.nid.",
            ],
            'bid' => [
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
                'description' => "The book ID is the {book}.nid of the top-level page.",
            ],
            'pid' => [
                'description' => 'The parent ID (pid) is the id of the node above in the hierarchy, or zero if the node is at the top level in its outline.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'has_children' => [
                'description' => 'Flag indicating whether any nodes have this node as a parent (1 = children exist, 0 = no children).',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
                'size' => 'small',
            ],
            'weight' => [
                'description' => 'Weight among book entries in the same book at the same depth.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ],
            'depth' => [
                'description' => 'The depth relative to the top level. A link with pid == 0 will have depth == 1.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
                'size' => 'small',
            ],
            'p1' => [
                'description' => 'The first nid in the materialized path. If N = depth, then pN must equal the nid. If depth > 1 then p(N-1) must equal the pid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p2' => [
                'description' => 'The second nid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p3' => [
                'description' => 'The third nid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p4' => [
                'description' => 'The fourth nid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p5' => [
                'description' => 'The fifth nid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p6' => [
                'description' => 'The sixth nid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p7' => [
                'description' => 'The seventh nid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p8' => [
                'description' => 'The eighth nid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p9' => [
                'description' => 'The ninth nid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
        ],
        'primary key' => [
            'nid',
        ],
        'indexes' => [
            'book_parents' => [
                'bid',
                'p1',
                'p2',
                'p3',
                'p4',
                'p5',
                'p6',
                'p7',
                'p8',
                'p9',
            ],
        ],
    ];
    return $schema;
}

Functions

Title Deprecated Summary
book_schema Implements hook_schema().
book_uninstall Implements hook_uninstall().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.