You are here

function taxonomy_check_vocabulary_hierarchy in Drupal 8

Same name and namespace in other branches
  1. 6 modules/taxonomy/taxonomy.module \taxonomy_check_vocabulary_hierarchy()
  2. 7 modules/taxonomy/taxonomy.module \taxonomy_check_vocabulary_hierarchy()

Checks the hierarchy flag of a vocabulary.

Checks the current parents of all terms in a vocabulary. If no term has parent terms then the vocabulary will be given a hierarchy of VocabularyInterface::HIERARCHY_DISABLED. If any term has a single parent then the vocabulary will be given a hierarchy of VocabularyInterface::HIERARCHY_SINGLE. If any term has multiple parents then the vocabulary will be given a hierarchy of VocabularyInterface::HIERARCHY_MULTIPLE.

Parameters

\Drupal\taxonomy\VocabularyInterface $vocabulary: A taxonomy vocabulary entity.

$changed_term: An array of the term structure that was updated.

Return value

int An integer that represents the level of the vocabulary's hierarchy.

Deprecated

in drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal\taxonomy\TermStorage::getVocabularyHierarchyType() instead.

File

core/modules/taxonomy/taxonomy.module, line 166
Enables the organization of content into categories.

Code

function taxonomy_check_vocabulary_hierarchy(VocabularyInterface $vocabulary, $changed_term) {
  @trigger_error('taxonomy_check_vocabulary_hierarchy() is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.x. Use \\Drupal\\taxonomy\\TermStorage::getVocabularyHierarchyType() instead.', E_USER_DEPRECATED);
  return \Drupal::entityTypeManager()
    ->getStorage('taxonomy_term')
    ->getVocabularyHierarchyType($vocabulary
    ->id());
}