annotate core/modules/taxonomy/src/TermStorageInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\taxonomy;
Chris@0 4
Chris@0 5 use Drupal\Core\Entity\EntityInterface;
Chris@0 6 use Drupal\Core\Entity\ContentEntityStorageInterface;
Chris@0 7
Chris@0 8 /**
Chris@0 9 * Defines an interface for taxonomy_term entity storage classes.
Chris@0 10 */
Chris@0 11 interface TermStorageInterface extends ContentEntityStorageInterface {
Chris@0 12
Chris@0 13 /**
Chris@0 14 * Removed reference to terms from term_hierarchy.
Chris@0 15 *
Chris@0 16 * @param array $tids
Chris@0 17 * Array of terms that need to be removed from hierarchy.
Chris@17 18 *
Chris@17 19 * @todo Remove this method in Drupal 9.0.x. Now the parent references are
Chris@17 20 * automatically cleared when deleting a taxonomy term.
Chris@17 21 * https://www.drupal.org/node/2785693
Chris@0 22 */
Chris@0 23 public function deleteTermHierarchy($tids);
Chris@0 24
Chris@0 25 /**
Chris@0 26 * Updates terms hierarchy information with the hierarchy trail of it.
Chris@0 27 *
Chris@0 28 * @param \Drupal\Core\Entity\EntityInterface $term
Chris@0 29 * Term entity that needs to be added to term hierarchy information.
Chris@17 30 *
Chris@17 31 * @todo remove this method Drupal 9.0.x. Now the parent references are
Chris@17 32 * automatically updates when when a taxonomy term is added/updated.
Chris@17 33 * https://www.drupal.org/node/2785693
Chris@0 34 */
Chris@0 35 public function updateTermHierarchy(EntityInterface $term);
Chris@0 36
Chris@0 37 /**
Chris@0 38 * Finds all parents of a given term ID.
Chris@0 39 *
Chris@0 40 * @param int $tid
Chris@0 41 * Term ID to retrieve parents for.
Chris@0 42 *
Chris@0 43 * @return \Drupal\taxonomy\TermInterface[]
Chris@0 44 * An array of term objects which are the parents of the term $tid.
Chris@0 45 */
Chris@0 46 public function loadParents($tid);
Chris@0 47
Chris@0 48 /**
Chris@0 49 * Finds all ancestors of a given term ID.
Chris@0 50 *
Chris@0 51 * @param int $tid
Chris@0 52 * Term ID to retrieve ancestors for.
Chris@0 53 *
Chris@0 54 * @return \Drupal\taxonomy\TermInterface[]
Chris@0 55 * An array of term objects which are the ancestors of the term $tid.
Chris@0 56 */
Chris@0 57 public function loadAllParents($tid);
Chris@0 58
Chris@0 59 /**
Chris@0 60 * Finds all children of a term ID.
Chris@0 61 *
Chris@0 62 * @param int $tid
Chris@0 63 * Term ID to retrieve children for.
Chris@0 64 * @param string $vid
Chris@0 65 * An optional vocabulary ID to restrict the child search.
Chris@0 66 *
Chris@0 67 * @return \Drupal\taxonomy\TermInterface[]
Chris@0 68 * An array of term objects that are the children of the term $tid.
Chris@0 69 */
Chris@0 70 public function loadChildren($tid, $vid = NULL);
Chris@0 71
Chris@0 72 /**
Chris@0 73 * Finds all terms in a given vocabulary ID.
Chris@0 74 *
Chris@0 75 * @param string $vid
Chris@0 76 * Vocabulary ID to retrieve terms for.
Chris@0 77 * @param int $parent
Chris@0 78 * The term ID under which to generate the tree. If 0, generate the tree
Chris@0 79 * for the entire vocabulary.
Chris@0 80 * @param int $max_depth
Chris@0 81 * The number of levels of the tree to return. Leave NULL to return all
Chris@0 82 * levels.
Chris@0 83 * @param bool $load_entities
Chris@0 84 * If TRUE, a full entity load will occur on the term objects. Otherwise
Chris@0 85 * they are partial objects queried directly from the {taxonomy_term_data}
Chris@0 86 * table to save execution time and memory consumption when listing large
Chris@0 87 * numbers of terms. Defaults to FALSE.
Chris@0 88 *
Chris@0 89 * @return object[]|\Drupal\taxonomy\TermInterface[]
Chris@0 90 * An array of term objects that are the children of the vocabulary $vid.
Chris@0 91 */
Chris@0 92 public function loadTree($vid, $parent = 0, $max_depth = NULL, $load_entities = FALSE);
Chris@0 93
Chris@0 94 /**
Chris@0 95 * Count the number of nodes in a given vocabulary ID.
Chris@0 96 *
Chris@0 97 * @param string $vid
Chris@0 98 * Vocabulary ID to retrieve terms for.
Chris@0 99 *
Chris@0 100 * @return int
Chris@0 101 * A count of the nodes in a given vocabulary ID.
Chris@0 102 */
Chris@0 103 public function nodeCount($vid);
Chris@0 104
Chris@0 105 /**
Chris@0 106 * Reset the weights for a given vocabulary ID.
Chris@0 107 *
Chris@0 108 * @param string $vid
Chris@0 109 * Vocabulary ID to retrieve terms for.
Chris@0 110 */
Chris@0 111 public function resetWeights($vid);
Chris@0 112
Chris@0 113 /**
Chris@0 114 * Returns all terms used to tag some given nodes.
Chris@0 115 *
Chris@0 116 * @param array $nids
Chris@0 117 * Node IDs to retrieve terms for.
Chris@0 118 * @param array $vocabs
Chris@0 119 * (optional) A vocabularies array to restrict the term search. Defaults to
Chris@0 120 * empty array.
Chris@0 121 * @param string $langcode
Chris@0 122 * (optional) A language code to restrict the term search. Defaults to NULL.
Chris@0 123 *
Chris@0 124 * @return array
Chris@0 125 * An array of nids and the term entities they were tagged with.
Chris@0 126 */
Chris@0 127 public function getNodeTerms(array $nids, array $vocabs = [], $langcode = NULL);
Chris@0 128
Chris@18 129 /**
Chris@18 130 * Returns the hierarchy type for a specific vocabulary ID.
Chris@18 131 *
Chris@18 132 * @param string $vid
Chris@18 133 * Vocabulary ID to retrieve the hierarchy type for.
Chris@18 134 *
Chris@18 135 * @return int
Chris@18 136 * The vocabulary hierarchy.
Chris@18 137 * Possible values:
Chris@18 138 * - VocabularyInterface::HIERARCHY_DISABLED: No parents.
Chris@18 139 * - VocabularyInterface::HIERARCHY_SINGLE: Single parent.
Chris@18 140 * - VocabularyInterface::HIERARCHY_MULTIPLE: Multiple parents.
Chris@18 141 */
Chris@18 142 public function getVocabularyHierarchyType($vid);
Chris@18 143
Chris@18 144 /**
Chris@18 145 * Gets a list of term IDs with pending revisions.
Chris@18 146 *
Chris@18 147 * @return int[]
Chris@18 148 * An array of term IDs which have pending revisions, keyed by their
Chris@18 149 * revision IDs.
Chris@18 150 *
Chris@18 151 * @internal
Chris@18 152 */
Chris@18 153 public function getTermIdsWithPendingRevisions();
Chris@18 154
Chris@0 155 }