You are here

public function StructureSyncCommands::importTaxonomies in Structure Sync 8

Same name and namespace in other branches
  1. 2.x src/Commands/StructureSyncCommands.php \Drupal\structure_sync\Commands\StructureSyncCommands::importTaxonomies()

Import the taxonomies

@validate-module-enabled structure_sync

@command import:taxonomies

@option choice Import style choice. @aliases it,import-taxonomies

1 call to StructureSyncCommands::importTaxonomies()
StructureSyncCommands::importAll in src/Commands/StructureSyncCommands.php
Import menu links, Taxonomy and Blocks

File

src/Commands/StructureSyncCommands.php, line 48

Class

StructureSyncCommands
A Drush commandfile.

Namespace

Drupal\structure_sync\Commands

Code

public function importTaxonomies($options = [
  'choice' => NULL,
]) {
  $this
    ->output()
    ->writeln('Importing taxonomies...');
  $choices = [
    'full' => 'Full',
    'safe' => 'Safe',
    'force' => 'Force',
  ];
  if (!$options['choice']) {
    $options['choice'] = $this
      ->io()
      ->choice(dt("What import style would you like?"), $choices);
  }
  if ($options['choice'] && array_key_exists($options['choice'], $choices)) {
    $this
      ->output()
      ->writeln('Using "' . $choices[$options['choice']] . '" import style');
    StructureSyncHelper::importTaxonomies([
      'style' => $options['choice'],
      'drush' => TRUE,
    ]);
    $this
      ->logger()
      ->info('Successfully imported taxonomies');
  }
  else {
    $this
      ->logger()
      ->warning('No choice made for import style on importing taxonomies');
  }
}