function ForumUninstallValidator::hasTermsForVocabulary
Same name in other branches
- 9 core/modules/forum/src/ForumUninstallValidator.php \Drupal\forum\ForumUninstallValidator::hasTermsForVocabulary()
- 8.9.x core/modules/forum/src/ForumUninstallValidator.php \Drupal\forum\ForumUninstallValidator::hasTermsForVocabulary()
- 11.x core/modules/forum/src/ForumUninstallValidator.php \Drupal\forum\ForumUninstallValidator::hasTermsForVocabulary()
Determines if there are any taxonomy terms for a specified vocabulary.
Parameters
\Drupal\taxonomy\VocabularyInterface $vocabulary: The vocabulary to check for terms.
Return value
bool TRUE if there are terms for this vocabulary, FALSE otherwise.
1 call to ForumUninstallValidator::hasTermsForVocabulary()
- ForumUninstallValidator::validate in core/
modules/ forum/ src/ ForumUninstallValidator.php - Determines the reasons a module can not be uninstalled.
File
-
core/
modules/ forum/ src/ ForumUninstallValidator.php, line 105
Class
- ForumUninstallValidator
- Prevents forum module from being uninstalled under certain conditions.
Namespace
Drupal\forumCode
protected function hasTermsForVocabulary(VocabularyInterface $vocabulary) {
$terms = $this->entityTypeManager
->getStorage('taxonomy_term')
->getQuery()
->condition('vid', $vocabulary->id())
->accessCheck(FALSE)
->range(0, 1)
->execute();
return !empty($terms);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.