You are here

public function ContentImport::createTerm in Content Import 8

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

To Create Terms if it is not available.

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

File

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

Class

ContentImport
Configure Content Import settings for this site.

Namespace

Drupal\contentimport\Form

Code

public function createTerm($voc, $term, $vid) {
  Term::create(array(
    'parent' => array(
      $voc,
    ),
    'name' => $term,
    'vid' => $vid,
  ))
    ->save();
  $termId = ContentImport::getTermId($term, $vid);
  return $termId;
}