You are here

public function ExifContent::createTerm in Exif 8

Same name and namespace in other branches
  1. 8.2 src/ExifContent.php \Drupal\exif\ExifContent::createTerm()

Create a taxonomy term.

Parameters

int $vid: Vocabulary Id.

string $name: Term name.

int $parent_term_id: Parent Term Id (or default, 0 if none).

Return value

\Drupal\Core\Entity\EntityInterface|\Drupal\taxonomy\Entity\Term The created Term.

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to ExifContent::createTerm()
ExifContent::handleTaxonomyField in src/ExifContent.php
Handle taxonomy field.

File

src/ExifContent.php, line 552

Class

ExifContent
Class ExifContent make link between drupal content and file content.

Namespace

Drupal\exif

Code

public function createTerm($vid, $name, $parent_term_id = 0) {
  $values = [
    'vid' => $vid,
    'name' => $name,
    'parent' => $parent_term_id,
  ];
  $term = Term::create($values);
  $term
    ->save();
  return $term;
}