You are here

public function CsvImporter::importTaxonomies in Hierarchical Taxonomy Import 8

This method returns a taxonomy term's id by going into depth.

File

src/Importer/CsvImporter.php, line 76

Class

CsvImporter

Namespace

Drupal\hierarchical_taxonomy_importer\Importer

Code

public function importTaxonomies($vid, $data, $reset) {

  // Checking for a valid VID
  if (empty($vid)) {
    throw new \Exception("Vocabulary ID is invalid or null");
  }

  /*if(!empty($data)) {
          // Checking fi teh row has only single record without the parent id
          $data_count = count($data);
          // This is applicable for the single record rows.
          if(empty($data[1]) && $data_count == 1) {
            // Setting up an array for the data of new taxonomy term.
            \Drupal\taxonomy\Entity\Term::create(
              [
                'name' => $data[0],
                'vid' => $vid,
              ]
            )->save();
          }
          elseif($data_count > 1) {

            $this->getNestedTid($vid, $data, $parent = 0, $count = 1, $reset);
          }
        }*/
  $this
    ->getNestedTid($vid, $data, $parent = 0, $reset);
}