3 namespace Drupal\taxonomy;
5 use Drupal\Core\Entity\EntityInterface;
6 use Drupal\Core\Entity\ContentEntityStorageInterface;
9 * Defines an interface for taxonomy_term entity storage classes.
11 interface TermStorageInterface extends ContentEntityStorageInterface {
14 * Removed reference to terms from term_hierarchy.
17 * Array of terms that need to be removed from hierarchy.
19 public function deleteTermHierarchy($tids);
22 * Updates terms hierarchy information with the hierarchy trail of it.
24 * @param \Drupal\Core\Entity\EntityInterface $term
25 * Term entity that needs to be added to term hierarchy information.
27 public function updateTermHierarchy(EntityInterface $term);
30 * Finds all parents of a given term ID.
33 * Term ID to retrieve parents for.
35 * @return \Drupal\taxonomy\TermInterface[]
36 * An array of term objects which are the parents of the term $tid.
38 public function loadParents($tid);
41 * Finds all ancestors of a given term ID.
44 * Term ID to retrieve ancestors for.
46 * @return \Drupal\taxonomy\TermInterface[]
47 * An array of term objects which are the ancestors of the term $tid.
49 public function loadAllParents($tid);
52 * Finds all children of a term ID.
55 * Term ID to retrieve children for.
57 * An optional vocabulary ID to restrict the child search.
59 * @return \Drupal\taxonomy\TermInterface[]
60 * An array of term objects that are the children of the term $tid.
62 public function loadChildren($tid, $vid = NULL);
65 * Finds all terms in a given vocabulary ID.
68 * Vocabulary ID to retrieve terms for.
70 * The term ID under which to generate the tree. If 0, generate the tree
71 * for the entire vocabulary.
72 * @param int $max_depth
73 * The number of levels of the tree to return. Leave NULL to return all
75 * @param bool $load_entities
76 * If TRUE, a full entity load will occur on the term objects. Otherwise
77 * they are partial objects queried directly from the {taxonomy_term_data}
78 * table to save execution time and memory consumption when listing large
79 * numbers of terms. Defaults to FALSE.
81 * @return object[]|\Drupal\taxonomy\TermInterface[]
82 * An array of term objects that are the children of the vocabulary $vid.
84 public function loadTree($vid, $parent = 0, $max_depth = NULL, $load_entities = FALSE);
87 * Count the number of nodes in a given vocabulary ID.
90 * Vocabulary ID to retrieve terms for.
93 * A count of the nodes in a given vocabulary ID.
95 public function nodeCount($vid);
98 * Reset the weights for a given vocabulary ID.
101 * Vocabulary ID to retrieve terms for.
103 public function resetWeights($vid);
106 * Returns all terms used to tag some given nodes.
109 * Node IDs to retrieve terms for.
110 * @param array $vocabs
111 * (optional) A vocabularies array to restrict the term search. Defaults to
113 * @param string $langcode
114 * (optional) A language code to restrict the term search. Defaults to NULL.
117 * An array of nids and the term entities they were tagged with.
119 public function getNodeTerms(array $nids, array $vocabs = [], $langcode = NULL);