You are here

public function StructureSyncCommands::importMenus in Structure Sync 8

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

Import menu links

@validate-module-enabled structure_sync

@command import:menus

@option choice Import style choice. @aliases im,import-menus

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

File

src/Commands/StructureSyncCommands.php, line 156

Class

StructureSyncCommands
A Drush commandfile.

Namespace

Drupal\structure_sync\Commands

Code

public function importMenus($options = [
  'choice' => NULL,
]) {
  $this
    ->output()
    ->writeln('Importing menu links...');
  $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::importMenuLinks([
      'style' => $options['choice'],
      'drush' => TRUE,
    ]);
    $this
      ->logger()
      ->info('Successfully imported menu links');
  }
  else {
    $this
      ->logger()
      ->warning('No choice made for import style on importing menu links');
  }
}