You are here

public function ContentImport::createVoc in Content Import 8

Same name and namespace in other branches
  1. 8.3 src/Form/ContentImport.php \Drupal\contentimport\Form\ContentImport::createVoc()
  2. 8.4 src/Form/ContentImport.php \Drupal\contentimport\Form\ContentImport::createVoc()

To Create Terms if it is not available.

1 call to ContentImport::createVoc()
ContentImport::getTermReference in src/Form/ContentImport.php
To get Reference field ids.

File

src/Form/ContentImport.php, line 133
Contains \Drupal\contentimport\Form\ContentImport.

Class

ContentImport
Configure Content Import settings for this site.

Namespace

Drupal\contentimport\Form

Code

public function createVoc($vid, $voc) {
  $vocabulary = \Drupal\taxonomy\Entity\Vocabulary::create(array(
    'vid' => $vid,
    'machine_name' => $vid,
    'name' => $voc,
  ));
  $vocabulary
    ->save();
}