You are here

public function MappingEditForm::getVocabularyId in GatherContent 8.3

Get vocabulary identifier for field in content type.

Parameters

string $field_name: Name of local field.

Return value

string Identifier of vocabulary.

1 call to MappingEditForm::getVocabularyId()
MappingEditForm::submitForm in src/Form/MappingEditForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…

File

src/Form/MappingEditForm.php, line 1322

Class

MappingEditForm
Class MappingEditForm.

Namespace

Drupal\gathercontent\Form

Code

public function getVocabularyId($field_name) {

  // Load vocabulary.
  $field_config = FieldConfig::loadByName('node', $this->contentType, $field_name);
  $settings = $field_config
    ->getSetting('handler_settings');

  /** @var \Drupal\taxonomy\Entity\Term[] $terms */
  if (!empty($settings['auto_create_bundle'])) {
    $vid = $settings['auto_create_bundle'];
    return $vid;
  }
  else {
    $vid = reset($settings['target_bundles']);
    return $vid;
  }
}