You are here

protected function ForumUninstallValidator::hasTermsForVocabulary in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 119
Contains \Drupal\forum\ForumUninstallValidator.

Class

ForumUninstallValidator
Prevents forum module from being uninstalled whilst any forum nodes exist or there are any terms in the forum vocabulary.

Namespace

Drupal\forum

Code

protected function hasTermsForVocabulary(VocabularyInterface $vocabulary) {
  $terms = $this->queryFactory
    ->get('taxonomy_term')
    ->condition('vid', $vocabulary
    ->id())
    ->accessCheck(FALSE)
    ->range(0, 1)
    ->execute();
  return !empty($terms);
}