You are here

function hook_migrate_MIGRATION_ID_prepare_row in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate/migrate.api.php \hook_migrate_MIGRATION_ID_prepare_row()

Allows adding data to a row for a migration with the specified ID.

This provides the same functionality as hook_migrate_prepare_row() but removes the need to check the value of $migration->id().

Parameters

\Drupal\migrate\Row $row: The row being imported.

\Drupal\migrate\Plugin\MigrateSourceInterface $source: The source migration.

\Drupal\migrate\Plugin\MigrationInterface $migration: The current migration.

Related topics

File

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

Code

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