function TermDevelGenerate::deleteVocabularyTerms

Same name in other branches
  1. 4.x devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\TermDevelGenerate::deleteVocabularyTerms()

Deletes all terms of given vocabularies.

Parameters

array $vids: Array of vocabulary ids.

Return value

int The number of terms deleted.

1 call to TermDevelGenerate::deleteVocabularyTerms()
TermDevelGenerate::generateTerms in devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php
Generates taxonomy terms for a list of given vocabularies.

File

devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php, line 201

Class

TermDevelGenerate
Provides a TermDevelGenerate plugin.

Namespace

Drupal\devel_generate\Plugin\DevelGenerate

Code

protected function deleteVocabularyTerms(array $vids) : int {
    $tids = $this->vocabularyStorage
        ->getToplevelTids($vids);
    $terms = $this->termStorage
        ->loadMultiple($tids);
    $total_deleted = 0;
    foreach ($vids as $vid) {
        $total_deleted += count($this->termStorage
            ->loadTree($vid));
    }
    $this->termStorage
        ->delete($terms);
    return $total_deleted;
}