You are here

public function MigrateBatchExecutable::batchImport in Migrate Tools 8.5

Same name and namespace in other branches
  1. 8.4 src/MigrateBatchExecutable.php \Drupal\migrate_tools\MigrateBatchExecutable::batchImport()

Setup batch operations for running the migration.

File

src/MigrateBatchExecutable.php, line 100

Class

MigrateBatchExecutable
Defines a migrate executable class for batch migrations through UI.

Namespace

Drupal\migrate_tools

Code

public function batchImport() {

  // Create the batch operations for each migration that needs to be executed.
  // This includes the migration for this executable, but also the dependent
  // migrations.
  $operations = $this
    ->batchOperations([
    $this->migration,
  ], 'import', [
    'limit' => $this->itemLimit,
    'update' => $this->updateExistingRows,
    'force' => $this->checkDependencies,
    'sync' => $this->syncSource,
  ]);
  if (count($operations) > 0) {
    $batch = [
      'operations' => $operations,
      'title' => $this
        ->t('Migrating %migrate', [
        '%migrate' => $this->migration
          ->label(),
      ]),
      'init_message' => $this
        ->t('Start migrating %migrate', [
        '%migrate' => $this->migration
          ->label(),
      ]),
      'progress_message' => $this
        ->t('Migrating %migrate', [
        '%migrate' => $this->migration
          ->label(),
      ]),
      'error_message' => $this
        ->t('An error occurred while migrating %migrate.', [
        '%migrate' => $this->migration
          ->label(),
      ]),
      'finished' => '\\Drupal\\migrate_tools\\MigrateBatchExecutable::batchFinishedImport',
    ];
    batch_set($batch);
  }
}