You are here

public function MigrateManifestCommands::templateList in Migrate Manifest 8

Same name and namespace in other branches
  1. 8.2 src/Commands/MigrateManifestCommands.php \Drupal\migrate_manifest\Commands\MigrateManifestCommands::templateList()
  2. 3.x src/Commands/MigrateManifestCommands.php \Drupal\migrate_manifest\Commands\MigrateManifestCommands::templateList()

Lists migration templates available to run.

@command migrate:template:list @option tag Template tag @option as-yaml Create output as yaml that can be used as a manifest. @validate-module-enabled migrate_manifest @aliases migrate-template-list,mml

File

src/Commands/MigrateManifestCommands.php, line 69

Class

MigrateManifestCommands
Drush 9 Migrate manifest command.

Namespace

Drupal\migrate_manifest\Commands

Code

public function templateList($options = [
  'tag' => NULL,
  'as-yaml' => NULL,
]) {
  $tag = $options['tag'];
  $as_yaml = $options['as-yaml'];

  /** @var \Drupal\migrate_manifest\MigrateTemplateStorageInterface $template_storage */
  $template_storage = \Drupal::service('migrate_manifest.template_storage');
  if ($tag) {
    $templates = $template_storage
      ->findTemplatesByTag($tag);
  }
  else {
    $templates = $template_storage
      ->getAllTemplates();
  }
  foreach ($templates as $template) {
    $this
      ->output()
      ->writeln(($as_yaml ? '- ' : '') . $template['id']);
  }
}