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 * @todo Remove this method in Drupal 9.0.x. Now the parent references are
20 * automatically cleared when deleting a taxonomy term.
21 * https://www.drupal.org/node/2785693
23 public function deleteTermHierarchy($tids);
26 * Updates terms hierarchy information with the hierarchy trail of it.
28 * @param \Drupal\Core\Entity\EntityInterface $term
29 * Term entity that needs to be added to term hierarchy information.
31 * @todo remove this method Drupal 9.0.x. Now the parent references are
32 * automatically updates when when a taxonomy term is added/updated.
33 * https://www.drupal.org/node/2785693
35 public function updateTermHierarchy(EntityInterface $term);
38 * Finds all parents of a given term ID.
41 * Term ID to retrieve parents for.
43 * @return \Drupal\taxonomy\TermInterface[]
44 * An array of term objects which are the parents of the term $tid.
46 public function loadParents($tid);
49 * Finds all ancestors of a given term ID.
52 * Term ID to retrieve ancestors for.
54 * @return \Drupal\taxonomy\TermInterface[]
55 * An array of term objects which are the ancestors of the term $tid.
57 public function loadAllParents($tid);
60 * Finds all children of a term ID.
63 * Term ID to retrieve children for.
65 * An optional vocabulary ID to restrict the child search.
67 * @return \Drupal\taxonomy\TermInterface[]
68 * An array of term objects that are the children of the term $tid.
70 public function loadChildren($tid, $vid = NULL);
73 * Finds all terms in a given vocabulary ID.
76 * Vocabulary ID to retrieve terms for.
78 * The term ID under which to generate the tree. If 0, generate the tree
79 * for the entire vocabulary.
80 * @param int $max_depth
81 * The number of levels of the tree to return. Leave NULL to return all
83 * @param bool $load_entities
84 * If TRUE, a full entity load will occur on the term objects. Otherwise
85 * they are partial objects queried directly from the {taxonomy_term_data}
86 * table to save execution time and memory consumption when listing large
87 * numbers of terms. Defaults to FALSE.
89 * @return object[]|\Drupal\taxonomy\TermInterface[]
90 * An array of term objects that are the children of the vocabulary $vid.
92 public function loadTree($vid, $parent = 0, $max_depth = NULL, $load_entities = FALSE);
95 * Count the number of nodes in a given vocabulary ID.
98 * Vocabulary ID to retrieve terms for.
101 * A count of the nodes in a given vocabulary ID.
103 public function nodeCount($vid);
106 * Reset the weights for a given vocabulary ID.
109 * Vocabulary ID to retrieve terms for.
111 public function resetWeights($vid);
114 * Returns all terms used to tag some given nodes.
117 * Node IDs to retrieve terms for.
118 * @param array $vocabs
119 * (optional) A vocabularies array to restrict the term search. Defaults to
121 * @param string $langcode
122 * (optional) A language code to restrict the term search. Defaults to NULL.
125 * An array of nids and the term entities they were tagged with.
127 public function getNodeTerms(array $nids, array $vocabs = [], $langcode = NULL);