annotate core/modules/book/book.install @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /**
Chris@0 4 * @file
Chris@0 5 * Install, update and uninstall functions for the book module.
Chris@0 6 */
Chris@0 7
Chris@0 8 /**
Chris@0 9 * Implements hook_uninstall().
Chris@0 10 */
Chris@0 11 function book_uninstall() {
Chris@0 12 // Clear book data out of the cache.
Chris@0 13 \Drupal::cache('data')->deleteAll();
Chris@0 14 }
Chris@0 15
Chris@0 16 /**
Chris@0 17 * Implements hook_schema().
Chris@0 18 */
Chris@0 19 function book_schema() {
Chris@0 20 $schema['book'] = [
Chris@0 21 'description' => 'Stores book outline information. Uniquely defines the location of each node in the book outline',
Chris@0 22 'fields' => [
Chris@0 23 'nid' => [
Chris@0 24 'type' => 'int',
Chris@0 25 'unsigned' => TRUE,
Chris@0 26 'not null' => TRUE,
Chris@0 27 'default' => 0,
Chris@0 28 'description' => "The book page's {node}.nid.",
Chris@0 29 ],
Chris@0 30 'bid' => [
Chris@0 31 'type' => 'int',
Chris@0 32 'unsigned' => TRUE,
Chris@0 33 'not null' => TRUE,
Chris@0 34 'default' => 0,
Chris@0 35 'description' => "The book ID is the {book}.nid of the top-level page.",
Chris@0 36 ],
Chris@0 37 'pid' => [
Chris@0 38 '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.',
Chris@0 39 'type' => 'int',
Chris@0 40 'unsigned' => TRUE,
Chris@0 41 'not null' => TRUE,
Chris@0 42 'default' => 0,
Chris@0 43 ],
Chris@0 44 'has_children' => [
Chris@0 45 'description' => 'Flag indicating whether any nodes have this node as a parent (1 = children exist, 0 = no children).',
Chris@0 46 'type' => 'int',
Chris@0 47 'not null' => TRUE,
Chris@0 48 'default' => 0,
Chris@0 49 'size' => 'small',
Chris@0 50 ],
Chris@0 51 'weight' => [
Chris@0 52 'description' => 'Weight among book entries in the same book at the same depth.',
Chris@0 53 'type' => 'int',
Chris@0 54 'not null' => TRUE,
Chris@0 55 'default' => 0,
Chris@0 56 ],
Chris@0 57 'depth' => [
Chris@0 58 'description' => 'The depth relative to the top level. A link with pid == 0 will have depth == 1.',
Chris@0 59 'type' => 'int',
Chris@0 60 'not null' => TRUE,
Chris@0 61 'default' => 0,
Chris@0 62 'size' => 'small',
Chris@0 63 ],
Chris@0 64 'p1' => [
Chris@0 65 '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.',
Chris@0 66 'type' => 'int',
Chris@0 67 'unsigned' => TRUE,
Chris@0 68 'not null' => TRUE,
Chris@0 69 'default' => 0,
Chris@0 70 ],
Chris@0 71 'p2' => [
Chris@0 72 'description' => 'The second nid in the materialized path. See p1.',
Chris@0 73 'type' => 'int',
Chris@0 74 'unsigned' => TRUE,
Chris@0 75 'not null' => TRUE,
Chris@0 76 'default' => 0,
Chris@0 77 ],
Chris@0 78 'p3' => [
Chris@0 79 'description' => 'The third nid in the materialized path. See p1.',
Chris@0 80 'type' => 'int',
Chris@0 81 'unsigned' => TRUE,
Chris@0 82 'not null' => TRUE,
Chris@0 83 'default' => 0,
Chris@0 84 ],
Chris@0 85 'p4' => [
Chris@0 86 'description' => 'The fourth nid in the materialized path. See p1.',
Chris@0 87 'type' => 'int',
Chris@0 88 'unsigned' => TRUE,
Chris@0 89 'not null' => TRUE,
Chris@0 90 'default' => 0,
Chris@0 91 ],
Chris@0 92 'p5' => [
Chris@0 93 'description' => 'The fifth nid in the materialized path. See p1.',
Chris@0 94 'type' => 'int',
Chris@0 95 'unsigned' => TRUE,
Chris@0 96 'not null' => TRUE,
Chris@0 97 'default' => 0,
Chris@0 98 ],
Chris@0 99 'p6' => [
Chris@0 100 'description' => 'The sixth nid in the materialized path. See p1.',
Chris@0 101 'type' => 'int',
Chris@0 102 'unsigned' => TRUE,
Chris@0 103 'not null' => TRUE,
Chris@0 104 'default' => 0,
Chris@0 105 ],
Chris@0 106 'p7' => [
Chris@0 107 'description' => 'The seventh nid in the materialized path. See p1.',
Chris@0 108 'type' => 'int',
Chris@0 109 'unsigned' => TRUE,
Chris@0 110 'not null' => TRUE,
Chris@0 111 'default' => 0,
Chris@0 112 ],
Chris@0 113 'p8' => [
Chris@0 114 'description' => 'The eighth nid in the materialized path. See p1.',
Chris@0 115 'type' => 'int',
Chris@0 116 'unsigned' => TRUE,
Chris@0 117 'not null' => TRUE,
Chris@0 118 'default' => 0,
Chris@0 119 ],
Chris@0 120 'p9' => [
Chris@0 121 'description' => 'The ninth nid in the materialized path. See p1.',
Chris@0 122 'type' => 'int',
Chris@0 123 'unsigned' => TRUE,
Chris@0 124 'not null' => TRUE,
Chris@0 125 'default' => 0,
Chris@0 126 ],
Chris@0 127 ],
Chris@0 128 'primary key' => ['nid'],
Chris@0 129 'indexes' => [
Chris@0 130 'book_parents' => ['bid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'],
Chris@0 131 ],
Chris@0 132 ];
Chris@0 133
Chris@0 134 return $schema;
Chris@0 135 }