You are here

public function TermStorage::updateTermHierarchy in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::updateTermHierarchy()

Updates terms hierarchy information with the hierarchy trail of it.

Parameters

\Drupal\Core\Entity\EntityInterface $term: Term entity that needs to be added to term hierarchy information.

Overrides TermStorageInterface::updateTermHierarchy

File

core/modules/taxonomy/src/TermStorage.php, line 110
Contains \Drupal\taxonomy\TermStorage.

Class

TermStorage
Defines a Controller class for taxonomy terms.

Namespace

Drupal\taxonomy

Code

public function updateTermHierarchy(EntityInterface $term) {
  $query = $this->database
    ->insert('taxonomy_term_hierarchy')
    ->fields(array(
    'tid',
    'parent',
  ));
  foreach ($term->parent as $parent) {
    $query
      ->values(array(
      'tid' => $term
        ->id(),
      'parent' => (int) $parent->target_id,
    ));
  }
  $query
    ->execute();
}