Version 1
[yaffs-website] / web / core / modules / migrate / tests / modules / migrate_prepare_row_test / migrate_prepare_row_test.module
1 <?php
2
3 /**
4  * @file
5  * Test module for testing the migration source plugin prepareRow() exception
6  * handling.
7  */
8
9 use Drupal\migrate\Plugin\MigrationInterface;
10 use Drupal\migrate\MigrateSkipRowException;
11 use Drupal\migrate\Plugin\MigrateSourceInterface;
12 use Drupal\migrate\Row;
13
14 /**
15  * Implements hook_migrate_prepare_row().
16  */
17 function migrate_prepare_row_test_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
18   // Test both options for save_to_map.
19   $data = $row->getSourceProperty('data');
20   if ($data == 'skip_and_record') {
21     // Record mapping but don't record a message.
22     throw new MigrateSkipRowException('', TRUE);
23   }
24   elseif ($data == 'skip_and_dont_record') {
25     // Don't record mapping but record a message.
26     throw new MigrateSkipRowException('skip_and_dont_record message', FALSE);
27   }
28 }