8.2.x migrate.api.php hook_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration)
8.0.x migrate.api.php hook_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration)
8.1.x migrate.api.php hook_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration)
8.3.x migrate.api.php hook_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration)

Allows adding data to a row before processing it.

For example, filter module used to store filter format settings in the variables table which now needs to be inside the filter format config file. So, it needs to be added here.

hook_migrate_MIGRATION_ID_prepare_row() is also available.

Related topics

1 function implements hook_migrate_prepare_row()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

migrate_prepare_row_test_migrate_prepare_row in core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.module
Implements hook_migrate_prepare_row().
5 invocations of hook_migrate_prepare_row()
MigrateSourceTest::testPrepareRow in core/modules/migrate/tests/src/Unit/MigrateSourceTest.php
Test basic row preparation.
MigrateSourceTest::testPrepareRowGlobalPrepareSkip in core/modules/migrate/tests/src/Unit/MigrateSourceTest.php
Test that global prepare hooks can skip rows.
MigrateSourceTest::testPrepareRowMigratePrepareSkip in core/modules/migrate/tests/src/Unit/MigrateSourceTest.php
Test that migrate specific prepare hooks can skip rows.
MigrateSourceTest::testPrepareRowPrepareException in core/modules/migrate/tests/src/Unit/MigrateSourceTest.php
Test that a skip exception during prepare hooks correctly skips.
SourcePluginBase::prepareRow in core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
Adds additional data to the row.

File

core/modules/migrate/migrate.api.php, line 99
Hooks provided by the Migrate module.

Code

function hook_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
  if ($migration->id() == 'd6_filter_formats') {
    $value = $source->getDatabase()->query('SELECT value FROM {variable} WHERE name = :name', array(':name' => 'mymodule_filter_foo_' . $row->getSourceProperty('format')))->fetchField();
    if ($value) {
      $row->setSourceProperty('settings:mymodule:foo', unserialize($value));
    }
  }
}