1. 8.5.x core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.module
  2. 8.0.x core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.module
  3. 8.1.x core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.module
  4. 8.2.x core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.module
  5. 8.3.x core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.module
  6. 8.4.x core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.module
  7. 8.6.x core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.module

Test module for testing the migration source plugin prepareRow() exception handling.

File

core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.module
View source
<?php

/**
 * @file
 * Test module for testing the migration source plugin prepareRow() exception
 * handling.
 */
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\MigrateSourceInterface;
use Drupal\migrate\Row;

/**
 * Implements hook_migrate_prepare_row().
 */
function migrate_prepare_row_test_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {

  // Test both options for save_to_map.
  $data = $row
    ->getSourceProperty('data');
  if ($data == 'skip_and_record') {

    // Record mapping but don't record a message.
    throw new MigrateSkipRowException('', TRUE);
  }
  elseif ($data == 'skip_and_dont_record') {

    // Don't record mapping but record a message.
    throw new MigrateSkipRowException('skip_and_dont_record message', FALSE);
  }
}

Functions