annotate core/modules/book/src/BookOutlineStorageInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\book;
Chris@0 4
Chris@0 5 /**
Chris@0 6 * Defines a common interface for book outline storage classes.
Chris@0 7 */
Chris@0 8 interface BookOutlineStorageInterface {
Chris@0 9
Chris@0 10 /**
Chris@0 11 * Gets books (the highest positioned book links).
Chris@0 12 *
Chris@0 13 * @return array
Chris@0 14 * An array of book IDs.
Chris@0 15 */
Chris@0 16 public function getBooks();
Chris@0 17
Chris@0 18 /**
Chris@0 19 * Checks if there are any books.
Chris@0 20 *
Chris@0 21 * @return bool
Chris@0 22 * TRUE if there are books, FALSE if not.
Chris@0 23 */
Chris@0 24 public function hasBooks();
Chris@0 25
Chris@0 26 /**
Chris@0 27 * Loads books.
Chris@0 28 *
Chris@0 29 * Each book entry consists of the following keys:
Chris@0 30 * - bid: The node ID of the main book.
Chris@0 31 * - nid: The node ID of the book entry itself.
Chris@0 32 * - pid: The parent node ID of the book.
Chris@0 33 * - has_children: A boolean to indicate whether the book has children.
Chris@0 34 * - weight: The weight of the book entry to order siblings.
Chris@0 35 * - depth: The depth in the menu hierarchy the entry is placed into.
Chris@0 36 *
Chris@0 37 * @param array $nids
Chris@0 38 * An array of node IDs.
Chris@0 39 * @param bool $access
Chris@0 40 * Whether access checking should be taken into account.
Chris@0 41 *
Chris@0 42 * @return array
Chris@0 43 * Array of loaded book items.
Chris@0 44 */
Chris@0 45 public function loadMultiple($nids, $access = TRUE);
Chris@0 46
Chris@0 47 /**
Chris@0 48 * Gets child relative depth.
Chris@0 49 *
Chris@0 50 * @param array $book_link
Chris@0 51 * The book link.
Chris@0 52 * @param int $max_depth
Chris@0 53 * The maximum supported depth of the book tree.
Chris@0 54 *
Chris@0 55 * @return int
Chris@0 56 * The depth of the searched book.
Chris@0 57 */
Chris@0 58 public function getChildRelativeDepth($book_link, $max_depth);
Chris@0 59
Chris@0 60 /**
Chris@0 61 * Deletes a book entry.
Chris@0 62 *
Chris@0 63 * @param int $nid
Chris@0 64 * Deletes a book entry.
Chris@0 65 *
Chris@0 66 * @return mixed
Chris@0 67 * Number of deleted book entries.
Chris@0 68 */
Chris@0 69 public function delete($nid);
Chris@0 70
Chris@0 71 /**
Chris@14 72 * Loads book's children using its parent ID.
Chris@0 73 *
Chris@0 74 * @param int $pid
Chris@0 75 * The book's parent ID.
Chris@0 76 *
Chris@0 77 * @return array
Chris@0 78 * Array of loaded book items.
Chris@0 79 */
Chris@0 80 public function loadBookChildren($pid);
Chris@0 81
Chris@0 82 /**
Chris@0 83 * Builds tree data used for the menu tree.
Chris@0 84 *
Chris@0 85 * @param int $bid
Chris@0 86 * The ID of the book that we are building the tree for.
Chris@0 87 * @param array $parameters
Chris@0 88 * An associative array of build parameters. For info about individual
Chris@0 89 * parameters see BookManager::bookTreeBuild().
Chris@0 90 * @param int $min_depth
Chris@0 91 * The minimum depth of book links in the resulting tree.
Chris@0 92 * @param int $max_depth
Chris@0 93 * The maximum supported depth of the book tree.
Chris@0 94 *
Chris@0 95 * @return array
Chris@0 96 * Array of loaded book links.
Chris@0 97 */
Chris@0 98 public function getBookMenuTree($bid, $parameters, $min_depth, $max_depth);
Chris@0 99
Chris@0 100 /**
Chris@0 101 * Inserts a book link.
Chris@0 102 *
Chris@0 103 * @param array $link
Chris@0 104 * The link array to be inserted in the database.
Chris@0 105 * @param array $parents
Chris@0 106 * The array of parent ids for the link to be inserted.
Chris@0 107 *
Chris@0 108 * @return mixed
Chris@0 109 * The last insert ID of the query, if one exists.
Chris@0 110 */
Chris@0 111 public function insert($link, $parents);
Chris@0 112
Chris@0 113 /**
Chris@0 114 * Updates book reference for links that were moved between books.
Chris@0 115 *
Chris@0 116 * @param int $nid
Chris@0 117 * The nid of the book entry to be updated.
Chris@0 118 * @param array $fields
Chris@0 119 * The array of fields to be updated.
Chris@0 120 *
Chris@0 121 * @return mixed
Chris@0 122 * The number of rows matched by the update query.
Chris@0 123 */
Chris@0 124 public function update($nid, $fields);
Chris@0 125
Chris@0 126 /**
Chris@0 127 * Update the book ID of the book link that it's being moved.
Chris@0 128 *
Chris@0 129 * @param int $bid
Chris@0 130 * The ID of the book whose children we move.
Chris@0 131 * @param array $original
Chris@0 132 * The original parent of the book link.
Chris@0 133 * @param array $expressions
Chris@0 134 * Array of expressions to be added to the query.
Chris@0 135 * @param int $shift
Chris@0 136 * The difference in depth between the old and the new position of the
Chris@0 137 * element being moved.
Chris@0 138 *
Chris@0 139 * @return mixed
Chris@0 140 * The number of rows matched by the update query.
Chris@0 141 */
Chris@0 142 public function updateMovedChildren($bid, $original, $expressions, $shift);
Chris@0 143
Chris@0 144 /**
Chris@0 145 * Count the number of original link children.
Chris@0 146 *
Chris@0 147 * @param array $original
Chris@0 148 * The book link array.
Chris@0 149 *
Chris@0 150 * @return int
Chris@0 151 * Number of children.
Chris@0 152 */
Chris@0 153 public function countOriginalLinkChildren($original);
Chris@0 154
Chris@0 155 /**
Chris@0 156 * Get book subtree.
Chris@0 157 *
Chris@0 158 * @param array $link
Chris@0 159 * A fully loaded book link.
Chris@0 160 * @param int $max_depth
Chris@0 161 * The maximum supported depth of the book tree.
Chris@0 162 *
Chris@0 163 * @return array
Chris@0 164 * Array of unordered subtree book items.
Chris@0 165 */
Chris@0 166 public function getBookSubtree($link, $max_depth);
Chris@0 167
Chris@0 168 }