public function TaxonomyImporterForm::getVocabularies in Hierarchical Taxonomy Import 8
This method returns the list of existing vocabularies.
Return value
mixed List of existing Vocabularies in an associative array's form.
1 call to TaxonomyImporterForm::getVocabularies()
- TaxonomyImporterForm::buildForm in src/
Form/ TaxonomyImporterForm.php - Form constructor.
File
- src/
Form/ TaxonomyImporterForm.php, line 141
Class
- TaxonomyImporterForm
- Class TaxonomyImporterForm.
Namespace
Drupal\hierarchical_taxonomy_importer\FormCode
public function getVocabularies() {
$output = [];
// Loading existing vocabularies.
$vocabularies = Vocabulary::loadMultiple();
// If vocabularies are not empty then load them to an array one by one
// Vocabulary ID would be used as offset and label as value of array on that
// offset.
if (!empty($vocabularies)) {
// Traversal of vocabularies is taking place and preparing an options array.
foreach ($vocabularies as $vocabulary) {
$output[$vocabulary
->id()] = $vocabulary
->get('name');
}
}
// Return the output back to the form.
return $output;
}