You are here

public function StructureSyncCommands::importBlocks in Structure Sync 8

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

Import blocks

@validate-module-enabled structure_sync

@command import:blocks

@option choice Import style choice. @aliases ib,import-blocks

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

File

src/Commands/StructureSyncCommands.php, line 102

Class

StructureSyncCommands
A Drush commandfile.

Namespace

Drupal\structure_sync\Commands

Code

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