You are here

protected function MerciBundleUninstallValidator::hasTermsForVocabulary in MERCI (Manage Equipment Reservations, Checkout and Inventory) 8.2

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.

File

src/MerciBundleUninstallValidator.php, line 98
Contains \Drupal\merci\MerciBundleUninstallValidator.

Class

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

Namespace

Drupal\merci

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);
}